mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-01-21 22:33:24 +08:00
* Upgrade maximum supported CMake version to 3.27 to fix warning with CMP0148 policy (#4785) * Update `macos_brew_install_llvm` pipeline to use expected Python installation * Fix `Python_EXECUTABLE` Cmake variable typo * Apply suggestions from code review * fix: use FindPython for CMake 3.18+ by default for pybind11's tests Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * tests: fix issues with finding Python Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * tests: also set executable on subdir tests Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix(cmake): correct logic for FindPython Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update ci.yml * Revert "Update ci.yml" This reverts commit 33798adf3f3892ac4b78da8d3d91d3b27611bbe5. --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
40 lines
1.3 KiB
CMake
40 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
project(test_installed_module CXX)
|
|
|
|
# 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.27)
|
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
|
else()
|
|
cmake_policy(VERSION 3.27)
|
|
endif()
|
|
|
|
project(test_installed_function CXX)
|
|
|
|
find_package(pybind11 CONFIG REQUIRED)
|
|
message(
|
|
STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${pybind11_INCLUDE_DIRS}")
|
|
|
|
pybind11_add_module(test_installed_function SHARED NO_EXTRAS ../main.cpp)
|
|
set_target_properties(test_installed_function PROPERTIES OUTPUT_NAME test_cmake_build)
|
|
|
|
if(DEFINED Python_EXECUTABLE)
|
|
set(_Python_EXECUTABLE "${Python_EXECUTABLE}")
|
|
elseif(DEFINED PYTHON_EXECUTABLE)
|
|
set(_Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
|
|
else()
|
|
message(FATAL_ERROR "No Python executable defined (should not be possible at this stage)")
|
|
endif()
|
|
|
|
add_custom_target(
|
|
check_installed_function
|
|
${CMAKE_COMMAND}
|
|
-E
|
|
env
|
|
PYTHONPATH=$<TARGET_FILE_DIR:test_installed_function>
|
|
${_Python_EXECUTABLE}
|
|
${PROJECT_SOURCE_DIR}/../test.py
|
|
${PROJECT_NAME}
|
|
DEPENDS test_installed_function)
|