Warning, /jana2/src/python/externals/pybind11-2.10.3/tests/test_cmake_build/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # Built-in in CMake 3.5+
0002 include(CMakeParseArguments)
0003
0004 add_custom_target(test_cmake_build)
0005
0006 function(pybind11_add_build_test name)
0007 cmake_parse_arguments(ARG "INSTALL" "" "" ${ARGN})
0008
0009 set(build_options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
0010
0011 if(PYBIND11_FINDPYTHON)
0012 list(APPEND build_options "-DPYBIND11_FINDPYTHON=${PYBIND11_FINDPYTHON}")
0013
0014 if(DEFINED Python_ROOT_DIR)
0015 list(APPEND build_options "-DPython_ROOT_DIR=${Python_ROOT_DIR}")
0016 endif()
0017
0018 list(APPEND build_options "-DPython_EXECUTABLE=${Python_EXECUTABLE}")
0019 else()
0020 list(APPEND build_options "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
0021 endif()
0022
0023 if(DEFINED CMAKE_CXX_STANDARD)
0024 list(APPEND build_options "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
0025 endif()
0026
0027 if(NOT ARG_INSTALL)
0028 list(APPEND build_options "-Dpybind11_SOURCE_DIR=${pybind11_SOURCE_DIR}")
0029 else()
0030 list(APPEND build_options "-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install")
0031 endif()
0032
0033 add_custom_target(
0034 test_build_${name}
0035 ${CMAKE_CTEST_COMMAND}
0036 --build-and-test
0037 "${CMAKE_CURRENT_SOURCE_DIR}/${name}"
0038 "${CMAKE_CURRENT_BINARY_DIR}/${name}"
0039 --build-config
0040 Release
0041 --build-noclean
0042 --build-generator
0043 ${CMAKE_GENERATOR}
0044 $<$<BOOL:${CMAKE_GENERATOR_PLATFORM}>:--build-generator-platform>
0045 ${CMAKE_GENERATOR_PLATFORM}
0046 --build-makeprogram
0047 ${CMAKE_MAKE_PROGRAM}
0048 --build-target
0049 check_${name}
0050 --build-options
0051 ${build_options})
0052 if(ARG_INSTALL)
0053 add_dependencies(test_build_${name} mock_install)
0054 endif()
0055 add_dependencies(test_cmake_build test_build_${name})
0056 endfunction()
0057
0058 possibly_uninitialized(PYTHON_MODULE_EXTENSION Python_INTERPRETER_ID)
0059
0060 pybind11_add_build_test(subdirectory_function)
0061 pybind11_add_build_test(subdirectory_target)
0062 if("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy")
0063 message(STATUS "Skipping embed test on PyPy")
0064 else()
0065 pybind11_add_build_test(subdirectory_embed)
0066 endif()
0067
0068 if(PYBIND11_INSTALL)
0069 add_custom_target(
0070 mock_install ${CMAKE_COMMAND} "-DCMAKE_INSTALL_PREFIX=${pybind11_BINARY_DIR}/mock_install" -P
0071 "${pybind11_BINARY_DIR}/cmake_install.cmake")
0072
0073 pybind11_add_build_test(installed_function INSTALL)
0074 pybind11_add_build_test(installed_target INSTALL)
0075 if(NOT ("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy"
0076 ))
0077 pybind11_add_build_test(installed_embed INSTALL)
0078 endif()
0079 endif()
0080
0081 add_dependencies(check test_cmake_build)
0082
0083 add_subdirectory(subdirectory_target EXCLUDE_FROM_ALL)
0084 add_subdirectory(subdirectory_embed EXCLUDE_FROM_ALL)