mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 13:45:10 +00:00
daea1130b4
* 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 33798adf3f
.
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
81 lines
2.5 KiB
CMake
81 lines
2.5 KiB
CMake
add_custom_target(test_cmake_build)
|
|
|
|
function(pybind11_add_build_test name)
|
|
cmake_parse_arguments(ARG "INSTALL" "" "" ${ARGN})
|
|
|
|
set(build_options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
|
|
|
list(APPEND build_options "-DPYBIND11_FINDPYTHON=${PYBIND11_FINDPYTHON}")
|
|
if(PYBIND11_FINDPYTHON)
|
|
if(DEFINED Python_ROOT_DIR)
|
|
list(APPEND build_options "-DPython_ROOT_DIR=${Python_ROOT_DIR}")
|
|
endif()
|
|
|
|
list(APPEND build_options "-DPython_EXECUTABLE=${Python_EXECUTABLE}")
|
|
else()
|
|
list(APPEND build_options "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
|
|
endif()
|
|
|
|
if(DEFINED CMAKE_CXX_STANDARD)
|
|
list(APPEND build_options "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
|
|
endif()
|
|
|
|
if(NOT ARG_INSTALL)
|
|
list(APPEND build_options "-Dpybind11_SOURCE_DIR=${pybind11_SOURCE_DIR}")
|
|
else()
|
|
list(APPEND build_options "-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install")
|
|
endif()
|
|
|
|
add_custom_target(
|
|
test_build_${name}
|
|
${CMAKE_CTEST_COMMAND}
|
|
--build-and-test
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${name}"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${name}"
|
|
--build-config
|
|
Release
|
|
--build-noclean
|
|
--build-generator
|
|
${CMAKE_GENERATOR}
|
|
$<$<BOOL:${CMAKE_GENERATOR_PLATFORM}>:--build-generator-platform>
|
|
${CMAKE_GENERATOR_PLATFORM}
|
|
--build-makeprogram
|
|
${CMAKE_MAKE_PROGRAM}
|
|
--build-target
|
|
check_${name}
|
|
--build-options
|
|
${build_options})
|
|
if(ARG_INSTALL)
|
|
add_dependencies(test_build_${name} mock_install)
|
|
endif()
|
|
add_dependencies(test_cmake_build test_build_${name})
|
|
endfunction()
|
|
|
|
possibly_uninitialized(PYTHON_MODULE_EXTENSION Python_INTERPRETER_ID)
|
|
|
|
pybind11_add_build_test(subdirectory_function)
|
|
pybind11_add_build_test(subdirectory_target)
|
|
if("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy")
|
|
message(STATUS "Skipping embed test on PyPy")
|
|
else()
|
|
pybind11_add_build_test(subdirectory_embed)
|
|
endif()
|
|
|
|
if(PYBIND11_INSTALL)
|
|
add_custom_target(
|
|
mock_install ${CMAKE_COMMAND} "-DCMAKE_INSTALL_PREFIX=${pybind11_BINARY_DIR}/mock_install" -P
|
|
"${pybind11_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
pybind11_add_build_test(installed_function INSTALL)
|
|
pybind11_add_build_test(installed_target INSTALL)
|
|
if(NOT ("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy"
|
|
))
|
|
pybind11_add_build_test(installed_embed INSTALL)
|
|
endif()
|
|
endif()
|
|
|
|
add_dependencies(check test_cmake_build)
|
|
|
|
add_subdirectory(subdirectory_target EXCLUDE_FROM_ALL)
|
|
add_subdirectory(subdirectory_embed EXCLUDE_FROM_ALL)
|