From f50f912a8c985f529c2d6766e58ddb779d9445a8 Mon Sep 17 00:00:00 2001 From: polmes Date: Sun, 13 Aug 2023 23:16:36 -0600 Subject: [PATCH 01/10] Upgrade maximum supported CMake version to 3.27 to fix warning with CMP0148 policy (#4785) --- CMakeLists.txt | 6 +++--- docs/advanced/embedding.rst | 2 +- docs/compiling.rst | 6 +++--- tests/CMakeLists.txt | 6 +++--- tests/test_cmake_build/installed_embed/CMakeLists.txt | 6 +++--- tests/test_cmake_build/installed_function/CMakeLists.txt | 6 +++--- tests/test_cmake_build/installed_target/CMakeLists.txt | 6 +++--- tests/test_cmake_build/subdirectory_embed/CMakeLists.txt | 6 +++--- tests/test_cmake_build/subdirectory_function/CMakeLists.txt | 6 +++--- tests/test_cmake_build/subdirectory_target/CMakeLists.txt | 6 +++--- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a1199dd2e..9b2ef2b9b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,13 +12,13 @@ endif() cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() if(_pybind11_cmp0148) diff --git a/docs/advanced/embedding.rst b/docs/advanced/embedding.rst index e6a1686f87..4cb6ebc68a 100644 --- a/docs/advanced/embedding.rst +++ b/docs/advanced/embedding.rst @@ -18,7 +18,7 @@ information, see :doc:`/compiling`. .. code-block:: cmake - cmake_minimum_required(VERSION 3.5...3.26) + cmake_minimum_required(VERSION 3.5...3.27) project(example) find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)` diff --git a/docs/compiling.rst b/docs/compiling.rst index 9d53904c42..f6a21691db 100644 --- a/docs/compiling.rst +++ b/docs/compiling.rst @@ -241,7 +241,7 @@ extension module can be created with just a few lines of code: .. code-block:: cmake - cmake_minimum_required(VERSION 3.5...3.26) + cmake_minimum_required(VERSION 3.5...3.27) project(example LANGUAGES CXX) add_subdirectory(pybind11) @@ -498,7 +498,7 @@ You can use these targets to build complex applications. For example, the .. code-block:: cmake - cmake_minimum_required(VERSION 3.5...3.26) + cmake_minimum_required(VERSION 3.5...3.27) project(example LANGUAGES CXX) find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11) @@ -556,7 +556,7 @@ information about usage in C++, see :doc:`/advanced/embedding`. .. code-block:: cmake - cmake_minimum_required(VERSION 3.5...3.26) + cmake_minimum_required(VERSION 3.5...3.27) project(example LANGUAGES CXX) find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d68067df6d..6ad729aae7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,13 +7,13 @@ cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() # Filter out items; print an optional message if any items filtered. This ignores extensions. diff --git a/tests/test_cmake_build/installed_embed/CMakeLists.txt b/tests/test_cmake_build/installed_embed/CMakeLists.txt index d9dcb45e42..89207a36da 100644 --- a/tests/test_cmake_build/installed_embed/CMakeLists.txt +++ b/tests/test_cmake_build/installed_embed/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() project(test_installed_embed CXX) diff --git a/tests/test_cmake_build/installed_function/CMakeLists.txt b/tests/test_cmake_build/installed_function/CMakeLists.txt index 2f4f642753..e752494e60 100644 --- a/tests/test_cmake_build/installed_function/CMakeLists.txt +++ b/tests/test_cmake_build/installed_function/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.5) project(test_installed_module CXX) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() project(test_installed_function CXX) diff --git a/tests/test_cmake_build/installed_target/CMakeLists.txt b/tests/test_cmake_build/installed_target/CMakeLists.txt index a981e236f5..3f7eb514e3 100644 --- a/tests/test_cmake_build/installed_target/CMakeLists.txt +++ b/tests/test_cmake_build/installed_target/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() project(test_installed_target CXX) diff --git a/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt b/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt index f286746b95..f074e427d9 100644 --- a/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +++ b/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() project(test_subdirectory_embed CXX) diff --git a/tests/test_cmake_build/subdirectory_function/CMakeLists.txt b/tests/test_cmake_build/subdirectory_function/CMakeLists.txt index 275a75c0b5..eacb3ab8ac 100644 --- a/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +++ b/tests/test_cmake_build/subdirectory_function/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() project(test_subdirectory_function CXX) diff --git a/tests/test_cmake_build/subdirectory_target/CMakeLists.txt b/tests/test_cmake_build/subdirectory_target/CMakeLists.txt index 37bb2c56e7..d5fc4f8132 100644 --- a/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +++ b/tests/test_cmake_build/subdirectory_target/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.5) -# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with # some versions of VS that have a patched CMake 3.11. This forces us to emulate # the behavior using the following workaround: -if(${CMAKE_VERSION} VERSION_LESS 3.26) +if(${CMAKE_VERSION} VERSION_LESS 3.27) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.26) + cmake_policy(VERSION 3.27) endif() project(test_subdirectory_target CXX) From bed84d6fcc71fd12a8cd51f75867e7ee9ef64b25 Mon Sep 17 00:00:00 2001 From: polmes Date: Sat, 19 Aug 2023 12:35:35 -0600 Subject: [PATCH 02/10] Update `macos_brew_install_llvm` pipeline to use expected Python installation --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 407db89cd4..a50bc44e8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1141,7 +1141,7 @@ jobs: -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=17 - -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + -DPYTHON_EXECUTABLE=/usr/local/bin/python3 - name: Build run: cmake --build . -j 2 @@ -1164,7 +1164,7 @@ jobs: -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=17 - -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + -DPYTHON_EXECUTABLE=/usr/local/bin/python3 "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" - name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE From 3e58a30c4ced12f81277d33bb8d216e464b271f1 Mon Sep 17 00:00:00 2001 From: polmes Date: Sat, 19 Aug 2023 16:01:35 -0600 Subject: [PATCH 03/10] Fix `Python_EXECUTABLE` Cmake variable typo --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a50bc44e8e..562ade2ebe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1141,7 +1141,7 @@ jobs: -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=17 - -DPYTHON_EXECUTABLE=/usr/local/bin/python3 + -DPython_EXECUTABLE=/usr/local/bin/python3 - name: Build run: cmake --build . -j 2 @@ -1164,7 +1164,7 @@ jobs: -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=17 - -DPYTHON_EXECUTABLE=/usr/local/bin/python3 + -DPython_EXECUTABLE=/usr/local/bin/python3 "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" - name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE From abb4e8b1200e81a5d7142be9592ee11a0ac17916 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Nov 2023 08:39:26 -0500 Subject: [PATCH 04/10] Apply suggestions from code review --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 562ade2ebe..407db89cd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1141,7 +1141,7 @@ jobs: -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=17 - -DPython_EXECUTABLE=/usr/local/bin/python3 + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build run: cmake --build . -j 2 @@ -1164,7 +1164,7 @@ jobs: -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=17 - -DPython_EXECUTABLE=/usr/local/bin/python3 + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" - name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE From 88fc7e12759d12278237112070500ff708db7c76 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 29 Nov 2023 16:26:39 -0500 Subject: [PATCH 05/10] fix: use FindPython for CMake 3.18+ by default for pybind11's tests Signed-off-by: Henry Schreiner --- CMakeLists.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b2ef2b9b1..a3d8bd288d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,9 +92,15 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) set(pybind11_system "") set_property(GLOBAL PROPERTY USE_FOLDERS ON) + if(CMAKE_VERSION VERSION_LESS "3.18") + set(_pybind11_findpython_default OFF) + else() + set(_pybind11_findpython_default ON) + endif() else() set(PYBIND11_MASTER_PROJECT OFF) set(pybind11_system SYSTEM) + set(_pybind11_findpython_default OFF) endif() # Options @@ -116,9 +122,20 @@ cmake_dependent_option( "Install pybind11 headers in Python include directory instead of default installation prefix" OFF "PYBIND11_INSTALL" OFF) -cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" OFF +cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default} "NOT CMAKE_VERSION VERSION_LESS 3.12" OFF) +# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests +# (makes transition easier while we support both modes). +if(PYBIND11_MASTER_PROJECT + AND PYBIND11_FINDPYTHON + AND DEFINED PYTHON_EXECUTABLE + AND NOT DEFINED Python_EXECUTABLE) + set(Python_EXECUTABLE + "${PYTHON_EXECUTABLE}" + CACHE INTERNAL "") +endif() + # NB: when adding a header don't forget to also add it to setup.py set(PYBIND11_HEADERS include/pybind11/detail/class.h From 987446187877640a90cdd77ebc1ddb0a54528fa1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 29 Nov 2023 17:01:03 -0500 Subject: [PATCH 06/10] tests: fix issues with finding Python Signed-off-by: Henry Schreiner --- .github/workflows/ci.yml | 15 ++++++++++++--- CMakeLists.txt | 4 +--- tests/test_cmake_build/CMakeLists.txt | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 407db89cd4..cccc594710 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -973,7 +973,10 @@ jobs: - name: Configure C++11 # LTO leads to many undefined reference like # `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&) - run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build + run: >- + cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON + -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") + -S . -B build - name: Build C++11 run: cmake --build build -j 2 @@ -991,7 +994,10 @@ jobs: run: git clean -fdx - name: Configure C++14 - run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2 + run: >- + cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON + -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") + -S . -B build2 - name: Build C++14 run: cmake --build build2 -j 2 @@ -1009,7 +1015,10 @@ jobs: run: git clean -fdx - name: Configure C++17 - run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3 + run: >- + cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON + -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") + -S . -B build3 - name: Build C++17 run: cmake --build build3 -j 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d8bd288d..1e75e99eb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,9 +131,7 @@ if(PYBIND11_MASTER_PROJECT AND PYBIND11_FINDPYTHON AND DEFINED PYTHON_EXECUTABLE AND NOT DEFINED Python_EXECUTABLE) - set(Python_EXECUTABLE - "${PYTHON_EXECUTABLE}" - CACHE INTERNAL "") + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") endif() # NB: when adding a header don't forget to also add it to setup.py diff --git a/tests/test_cmake_build/CMakeLists.txt b/tests/test_cmake_build/CMakeLists.txt index e5aa975cfc..f28bde08e5 100644 --- a/tests/test_cmake_build/CMakeLists.txt +++ b/tests/test_cmake_build/CMakeLists.txt @@ -5,9 +5,8 @@ function(pybind11_add_build_test name) set(build_options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") + list(APPEND build_options "-DPYBIND11_FINDPYTHON=${PYBIND11_FINDPYTHON}") if(PYBIND11_FINDPYTHON) - list(APPEND build_options "-DPYBIND11_FINDPYTHON=${PYBIND11_FINDPYTHON}") - if(DEFINED Python_ROOT_DIR) list(APPEND build_options "-DPython_ROOT_DIR=${Python_ROOT_DIR}") endif() From 574ee0cac1aa0c537569a277c1389ff0cc87c4c8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 1 Dec 2023 16:26:12 -0500 Subject: [PATCH 07/10] tests: also set executable on subdir tests Signed-off-by: Henry Schreiner --- tests/test_cmake_build/subdirectory_embed/CMakeLists.txt | 6 ++++++ tests/test_cmake_build/subdirectory_function/CMakeLists.txt | 6 ++++++ tests/test_cmake_build/subdirectory_target/CMakeLists.txt | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt b/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt index f074e427d9..7e71334357 100644 --- a/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +++ b/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt @@ -16,6 +16,12 @@ set(PYBIND11_INSTALL CACHE BOOL "") set(PYBIND11_EXPORT_NAME test_export) +# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests +# (makes transition easier while we support both modes). +if(DEFINED PYTHON_EXECUTABLE AND NOT DEFINED Python_EXECUTABLE) + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") +endif() + add_subdirectory("${pybind11_SOURCE_DIR}" pybind11) # Test basic target functionality diff --git a/tests/test_cmake_build/subdirectory_function/CMakeLists.txt b/tests/test_cmake_build/subdirectory_function/CMakeLists.txt index eacb3ab8ac..56b8b3d98f 100644 --- a/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +++ b/tests/test_cmake_build/subdirectory_function/CMakeLists.txt @@ -11,6 +11,12 @@ endif() project(test_subdirectory_function CXX) +# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests +# (makes transition easier while we support both modes). +if(DEFINED PYTHON_EXECUTABLE AND NOT DEFINED Python_EXECUTABLE) + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") +endif() + add_subdirectory("${pybind11_SOURCE_DIR}" pybind11) pybind11_add_module(test_subdirectory_function ../main.cpp) set_target_properties(test_subdirectory_function PROPERTIES OUTPUT_NAME test_cmake_build) diff --git a/tests/test_cmake_build/subdirectory_target/CMakeLists.txt b/tests/test_cmake_build/subdirectory_target/CMakeLists.txt index d5fc4f8132..72d880b37e 100644 --- a/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +++ b/tests/test_cmake_build/subdirectory_target/CMakeLists.txt @@ -11,6 +11,12 @@ endif() project(test_subdirectory_target CXX) +# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests +# (makes transition easier while we support both modes). +if(DEFINED PYTHON_EXECUTABLE AND NOT DEFINED Python_EXECUTABLE) + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") +endif() + add_subdirectory("${pybind11_SOURCE_DIR}" pybind11) add_library(test_subdirectory_target MODULE ../main.cpp) From adcf52c69ea5018cb3a3a91341f9dff4a681e3eb Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 1 Dec 2023 16:44:13 -0500 Subject: [PATCH 08/10] fix(cmake): correct logic for FindPython Signed-off-by: Henry Schreiner --- tools/pybind11NewTools.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pybind11NewTools.cmake b/tools/pybind11NewTools.cmake index 4b69486311..cd88a64500 100644 --- a/tools/pybind11NewTools.cmake +++ b/tools/pybind11NewTools.cmake @@ -54,7 +54,7 @@ if(NOT Python_FOUND AND NOT Python3_FOUND) # If we are in submodule mode, export the Python targets to global targets. # If this behavior is not desired, FindPython _before_ pybind11. if(NOT is_config - AND NOT Python_ARTIFACTS_INTERACTIVE + AND Python_ARTIFACTS_INTERACTIVE AND _pybind11_global_keyword STREQUAL "") if(TARGET Python::Python) set_property(TARGET Python::Python PROPERTY IMPORTED_GLOBAL TRUE) From 33798adf3f3892ac4b78da8d3d91d3b27611bbe5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 1 Dec 2023 17:41:26 -0500 Subject: [PATCH 09/10] Update ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cccc594710..c2cb10198f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1122,6 +1122,8 @@ jobs: - name: Show Clang++ version before brew install llvm run: clang++ --version + - run: brew update + - name: brew install llvm run: brew install llvm From a082e3a62b310754b2217ed87418e67b4522fff0 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 1 Dec 2023 23:04:57 -0500 Subject: [PATCH 10/10] Revert "Update ci.yml" This reverts commit 33798adf3f3892ac4b78da8d3d91d3b27611bbe5. --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2cb10198f..cccc594710 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1122,8 +1122,6 @@ jobs: - name: Show Clang++ version before brew install llvm run: clang++ --version - - run: brew update - - name: brew install llvm run: brew install llvm