|
| 1 | +# CMakeLists.txt -- Build system for the pybind11 multiple interpreters test suite |
| 2 | +# |
| 3 | +# Copyright (c) 2015 Wenzel Jakob <[email protected]> |
| 4 | +# |
| 5 | +# All rights reserved. Use of this source code is governed by a |
| 6 | +# BSD-style license that can be found in the LICENSE file. |
| 7 | + |
| 8 | +set(PYBIND11_MULTIPLE_INTERPRETERS_TEST_FILES test_multiple_interpreters.py) |
| 9 | + |
| 10 | +# These modules don't get mixed with other test modules because those aren't subinterpreter safe. |
| 11 | +pybind11_add_module(mod_per_interpreter_gil THIN_LTO mod_per_interpreter_gil.cpp) |
| 12 | +pybind11_add_module(mod_shared_interpreter_gil THIN_LTO mod_shared_interpreter_gil.cpp) |
| 13 | +pybind11_enable_warnings(mod_per_interpreter_gil) |
| 14 | +pybind11_enable_warnings(mod_shared_interpreter_gil) |
| 15 | + |
| 16 | +# Put the built modules to the parent directory in the cmake build tree. So they can be found by |
| 17 | +# the test scripts. |
| 18 | +set_target_properties(mod_per_interpreter_gil PROPERTIES LIBRARY_OUTPUT_DIRECTORY |
| 19 | + "$<1:${CMAKE_CURRENT_BINARY_DIR}>/..") |
| 20 | +set_target_properties(mod_shared_interpreter_gil PROPERTIES LIBRARY_OUTPUT_DIRECTORY |
| 21 | + "$<1:${CMAKE_CURRENT_BINARY_DIR}>/..") |
| 22 | + |
| 23 | +if(PYBIND11_TEST_SMART_HOLDER) |
| 24 | + target_compile_definitions( |
| 25 | + mod_per_interpreter_gil |
| 26 | + PUBLIC -DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE) |
| 27 | + target_compile_definitions( |
| 28 | + mod_shared_interpreter_gil |
| 29 | + PUBLIC -DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE) |
| 30 | +endif() |
| 31 | + |
| 32 | +add_dependencies(pytest mod_per_interpreter_gil mod_shared_interpreter_gil) |
| 33 | + |
| 34 | +# Convert relative to full file names and add to pytest test files |
| 35 | +list(TRANSFORM PYBIND11_MULTIPLE_INTERPRETERS_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") |
| 36 | +list(APPEND PYBIND11_ABS_PYTEST_FILES ${PYBIND11_MULTIPLE_INTERPRETERS_TEST_FILES}) |
| 37 | +set(PYBIND11_ABS_PYTEST_FILES |
| 38 | + ${PYBIND11_ABS_PYTEST_FILES} |
| 39 | + PARENT_SCOPE) |
0 commit comments