2017-06-25 13:16:34 +00:00
|
|
|
add_custom_target(test_cmake_build)
|
|
|
|
|
|
|
|
function(pybind11_add_build_test name)
|
2020-08-01 19:53:11 +00:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 1 ARG "INSTALL" "" "")
|
2017-06-25 13:16:34 +00:00
|
|
|
|
2020-07-30 20:20:10 +00:00
|
|
|
set(build_options
|
|
|
|
"-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install"
|
|
|
|
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
|
|
|
|
"-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}")
|
2020-07-28 04:43:12 +00:00
|
|
|
|
2020-08-01 02:45:19 +00:00
|
|
|
if(DEFINED CMAKE_CXX_STANDARD)
|
2020-07-28 04:43:12 +00:00
|
|
|
list(APPEND build_options "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
|
|
|
|
endif()
|
|
|
|
|
2017-06-25 13:16:34 +00:00
|
|
|
if(NOT ARG_INSTALL)
|
2020-07-28 04:43:12 +00:00
|
|
|
list(APPEND build_options "-DPYBIND11_PROJECT_DIR=${pybind11_SOURCE_DIR}")
|
2020-08-01 19:53:11 +00:00
|
|
|
else()
|
|
|
|
list(APPEND build_options "-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install")
|
2017-06-25 13:16:34 +00:00
|
|
|
endif()
|
|
|
|
|
2020-07-30 20:20:10 +00:00
|
|
|
add_custom_target(
|
2020-08-01 19:53:11 +00:00
|
|
|
test_build_${name}
|
2020-07-30 20:20:10 +00:00
|
|
|
${CMAKE_CTEST_COMMAND}
|
|
|
|
--build-and-test
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${name}"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${name}"
|
|
|
|
--build-config
|
|
|
|
Release
|
2017-06-25 13:16:34 +00:00
|
|
|
--build-noclean
|
2020-07-30 20:20:10 +00:00
|
|
|
--build-generator
|
|
|
|
${CMAKE_GENERATOR}
|
|
|
|
$<$<BOOL:${CMAKE_GENERATOR_PLATFORM}>:--build-generator-platform>
|
|
|
|
${CMAKE_GENERATOR_PLATFORM}
|
|
|
|
--build-makeprogram
|
|
|
|
${CMAKE_MAKE_PROGRAM}
|
|
|
|
--build-target
|
2020-08-01 19:53:11 +00:00
|
|
|
check_${name}
|
2020-07-30 20:20:10 +00:00
|
|
|
--build-options
|
|
|
|
${build_options})
|
2017-06-25 13:16:34 +00:00
|
|
|
if(ARG_INSTALL)
|
2020-08-01 19:53:11 +00:00
|
|
|
add_dependencies(test_build_${name} mock_install)
|
2017-06-25 13:16:34 +00:00
|
|
|
endif()
|
2020-08-01 19:53:11 +00:00
|
|
|
add_dependencies(test_cmake_build test_build_${name})
|
2017-06-25 13:16:34 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
pybind11_add_build_test(subdirectory_function)
|
|
|
|
pybind11_add_build_test(subdirectory_target)
|
|
|
|
if(NOT ${PYTHON_MODULE_EXTENSION} MATCHES "pypy")
|
|
|
|
pybind11_add_build_test(subdirectory_embed)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PYBIND11_INSTALL)
|
2020-07-30 20:20:10 +00:00
|
|
|
add_custom_target(
|
|
|
|
mock_install ${CMAKE_COMMAND} "-DCMAKE_INSTALL_PREFIX=${pybind11_BINARY_DIR}/mock_install" -P
|
|
|
|
"${pybind11_BINARY_DIR}/cmake_install.cmake")
|
2017-06-25 13:16:34 +00:00
|
|
|
|
|
|
|
pybind11_add_build_test(installed_function INSTALL)
|
|
|
|
pybind11_add_build_test(installed_target INSTALL)
|
|
|
|
if(NOT ${PYTHON_MODULE_EXTENSION} MATCHES "pypy")
|
|
|
|
pybind11_add_build_test(installed_embed INSTALL)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_dependencies(check test_cmake_build)
|