@@ -5,17 +5,23 @@ cmake_minimum_required(VERSION 3.22)
55
66# first we configure the tests as with other tests
77add_executable (runner-tests EXCLUDE_FROM_ALL )
8+
89mo2_configure_tests(runner-tests WARNINGS OFF )
910
1011set_target_properties (runner-tests PROPERTIES FOLDER tests/runner)
1112
13+ # link to runner
14+ target_link_libraries (runner-tests PUBLIC runner)
15+
16+ # linking to Python - this is not required to get proper linking but required so that
17+ # CMake generator variables will lookup appropriate DLLs for Python and update PATH
18+ # accordingly thanks to mo2_configure_tests
19+ target_link_libraries (runner-tests PUBLIC Python::Python)
20+
1221# add mocks
1322target_include_directories (runner-tests
1423 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /../mocks)
1524
16- # link to runner
17- target_link_libraries (runner-tests PUBLIC runner)
18-
1925set (PYLIB_DIR ${CMAKE_CURRENT_BINARY_DIR} /pylibs)
2026mo2_python_pip_install(runner-tests
2127 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /pylibs
@@ -26,20 +32,11 @@ mo2_python_pip_install(runner-tests
2632
2733add_dependencies (runner-tests mobase)
2834
29- # we set multiple properties, including:
30- # - updated PATH for DLLs (Qt, etc.), Python and runner
31- # - PYTHONPATH
32-
3335set (pythoncore "${PYTHON_ROOT} /PCbuild/amd64/pythoncore" )
3436set (pythoncorezip "${pythoncore} /python${Python_VERSION_SHORT} .zip" )
3537set (PYTHONPATH "${PYLIB_DIR} \\ ;$<TARGET_FILE_DIR:mobase>\\ ;${pythoncore} \\ ;${pythoncorezip} " )
3638
37- set (extra_paths "${MO2_INSTALL_PATH} /bin/dlls" )
38- string (APPEND extra_paths "\\ ;${PYTHON_ROOT} /PCbuild/amd64" )
39- string (APPEND extra_paths "\\ ;$<TARGET_FILE_DIR:runner>" )
4039set_tests_properties (${runner-tests_gtests}
4140 PROPERTIES
42- ENVIRONMENT "PLUGIN_DIR=${CMAKE_CURRENT_SOURCE_DIR} /plugins"
43- ENVIRONMENT_MODIFICATION
44- "PATH=path_list_prepend:${extra_paths} ;PYTHONPATH=set:${PYTHONPATH} "
41+ ENVIRONMENT "PLUGIN_DIR=${CMAKE_CURRENT_SOURCE_DIR} /plugins;PYTHONPATH=${PYTHONPATH} "
4542)
0 commit comments