-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (62 loc) · 2.07 KB
/
CMakeLists.txt
File metadata and controls
75 lines (62 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
cmake_minimum_required(VERSION 3.16)
# pytest
cmake_policy(SET CMP0144 NEW)
find_package(mo2-uibase CONFIG REQUIRED)
find_package(GTest REQUIRED)
set(PYLIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/pylibs)
set(UIBASE_PATH $<TARGET_FILE_DIR:mo2::uibase>)
add_custom_target(python-tests)
target_sources(python-tests
PRIVATE
conftest.py
test_argument_wrapper.py
test_filetree.py
test_functional.py
test_guessed_string.py
test_organizer.py
test_path_wrappers.py
test_qt_widgets.py
test_qt.py
test_shared_cpp_owner.py
)
add_test(NAME pytest
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/pylibs/bin/pytest.exe ${CMAKE_CURRENT_SOURCE_DIR} -s
)
set_tests_properties(pytest
PROPERTIES
DEPENDS python-tests
ENVIRONMENT_MODIFICATION
"PYTHONPATH=set:${PYLIB_DIR}\\;$<TARGET_FILE_DIR:mobase>;\
UIBASE_PATH=set:${UIBASE_PATH}"
)
mo2_python_pip_install(python-tests
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pylibs
PACKAGES pytest
PyQt${MO2_QT_VERSION_MAJOR}==${MO2_PYQT_VERSION}
PyQt${MO2_QT_VERSION_MAJOR}-Qt${MO2_QT_VERSION_MAJOR}==${MO2_QT_VERSION})
add_dependencies(python-tests mobase)
set_target_properties(python-tests PROPERTIES FOLDER tests/python)
file(GLOB test_files CONFIGURE_DEPENDS "test_*.cpp")
foreach (test_file ${test_files})
get_filename_component(target ${test_file} NAME_WLE)
string(REPLACE "test_" "" pymodule ${target})
pybind11_add_module(${target} EXCLUDE_FROM_ALL THIN_LTO ${test_file})
set_target_properties(${target}
PROPERTIES
CXX_STANDARD 23
OUTPUT_NAME ${pymodule}
FOLDER tests/python
LIBRARY_OUTPUT_DIRECTORY "${PYLIB_DIR}/mobase_tests")
if(DEFINED CMAKE_CONFIGURATION_TYPES)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config)
set_target_properties(${target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config} "${PYLIB_DIR}/mobase_tests")
endforeach()
endif()
target_link_libraries(${target} PRIVATE
mo2::uibase Qt6::Core Qt6::Widgets pybind11::qt pybind11::utils GTest::gmock)
target_include_directories(${target}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../mocks)
add_dependencies(python-tests ${target})
endforeach()