@@ -66,16 +66,14 @@ endif()
6666##############################################################################
6767# Find Python
6868##############################################################################
69- # First search for Python with Interpreter+Devel components, to allow the module
70- # to look for the interpreter that goes with the Python development library.
71- # Then if it could not find both, try looking for the development component
72- # only, but this time force the module to find it or fail (REQUIRED).
73- # Some of our toolchains (when crosscompiling for instance) have the Python
74- # library but not an interpreter that can run on the host.
75- find_package (Python COMPONENTS Development Interpreter )
76- if (NOT Python_FOUND)
77- find_package (Python REQUIRED COMPONENTS Development )
78- endif ()
69+ find_package (
70+ Python REQUIRED
71+ COMPONENTS
72+ Development.Module
73+ OPTIONAL_COMPONENTS
74+ Interpreter
75+ Development.Embed
76+ )
7977
8078##############################################################################
8179# Find Boost
@@ -323,47 +321,49 @@ if(BUILD_TESTING)
323321 qi::qi
324322 )
325323
326- add_executable (test_qipython )
327- target_sources (
328- test_qipython
329- PRIVATE
330- tests/common.hpp
331- tests/test_qipython.cpp
332- tests/test_guard.cpp
333- tests/test_types.cpp
334- tests/test_signal.cpp
335- tests/test_property.cpp
336- tests/test_object.cpp
337- tests/test_module.cpp
338- )
339- target_link_libraries (
340- test_qipython
324+ if (Python_Development.Embed_FOUND)
325+ add_executable (test_qipython )
326+ target_sources (
327+ test_qipython
328+ PRIVATE
329+ tests/common.hpp
330+ tests/test_qipython.cpp
331+ tests/test_guard.cpp
332+ tests/test_types.cpp
333+ tests/test_signal.cpp
334+ tests/test_property.cpp
335+ tests/test_object.cpp
336+ tests/test_module.cpp
337+ )
338+ target_link_libraries (
339+ test_qipython
340+ PRIVATE
341+ qi_python_objects
342+ cxx_standard
343+ Python::Python
344+ Boost::headers
345+ pybind11::pybind11
346+ GTest::gmock
347+ )
348+ gtest_discover_tests (test_qipython )
349+
350+ add_executable (test_qipython_local_interpreter )
351+ target_sources (
352+ test_qipython_local_interpreter
353+ PRIVATE
354+ tests/test_qipython_local_interpreter.cpp
355+ )
356+ target_link_libraries (
357+ test_qipython_local_interpreter
341358 PRIVATE
342- qi_python_objects
343- cxx_standard
344359 Python::Python
345- Boost::headers
346360 pybind11::pybind11
361+ qi_python_objects
362+ cxx_standard
347363 GTest::gmock
348- )
349- gtest_discover_tests (test_qipython )
350-
351- add_executable (test_qipython_local_interpreter )
352- target_sources (
353- test_qipython_local_interpreter
354- PRIVATE
355- tests/test_qipython_local_interpreter.cpp
356- )
357- target_link_libraries (
358- test_qipython_local_interpreter
359- PRIVATE
360- Python::Python
361- pybind11::pybind11
362- qi_python_objects
363- cxx_standard
364- GTest::gmock
365- )
366- gtest_discover_tests (test_qipython_local_interpreter )
364+ )
365+ gtest_discover_tests (test_qipython_local_interpreter )
366+ endif ()
367367
368368 if (NOT Python_Interpreter_FOUND)
369369 message (WARNING "tests: a compatible Python Interpreter was NOT found, Python tests are DISABLED." )
0 commit comments