Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.1 KiB
CMake
Raw Permalink Normal View History

2022-05-02 17:09:36 +02:00
cmake_minimum_required(VERSION 3.16)
# pytest
2024-05-25 13:15:10 +02:00
cmake_policy(SET CMP0144 NEW)
2025-05-29 11:03:51 +02:00
find_package(mo2-uibase CONFIG REQUIRED)
2022-05-02 17:09:36 +02:00
find_package(GTest REQUIRED)
set(PYLIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/pylibs)
2025-05-29 11:03:51 +02:00
set(UIBASE_PATH $<TARGET_FILE_DIR:mo2::uibase>)
2022-05-02 17:09:36 +02:00
add_custom_target(python-tests)
2025-05-29 11:03:51 +02:00
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
)
2022-05-02 17:09:36 +02:00
2022-05-05 14:21:24 +02:00
add_test(NAME pytest
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/pylibs/bin/pytest.exe ${CMAKE_CURRENT_SOURCE_DIR} -s
2022-05-02 17:09:36 +02:00
)
2022-05-05 14:21:24 +02:00
set_tests_properties(pytest
PROPERTIES
DEPENDS python-tests
2022-05-05 14:21:24 +02:00
ENVIRONMENT_MODIFICATION
"PYTHONPATH=set:${PYLIB_DIR}\\;$<TARGET_FILE_DIR:mobase>;\
2025-05-29 11:03:51 +02:00
UIBASE_PATH=set:${UIBASE_PATH}"
2022-05-05 14:21:24 +02:00
)
mo2_python_pip_install(python-tests
2022-05-02 17:09:36 +02:00
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pylibs
PACKAGES pytest
2025-05-29 11:03:51 +02:00
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)
2022-05-08 11:14:01 +02:00
set_target_properties(python-tests PROPERTIES FOLDER tests/python)
2022-05-02 17:09:36 +02:00
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})
2022-05-02 17:09:36 +02:00
set_target_properties(${target}
PROPERTIES
CXX_STANDARD 23
2022-05-02 17:09:36 +02:00
OUTPUT_NAME ${pymodule}
2022-05-08 11:14:01 +02:00
FOLDER tests/python
2022-05-02 17:09:36 +02:00
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()
2025-05-29 11:03:51 +02:00
target_link_libraries(${target} PRIVATE
mo2::uibase Qt6::Core Qt6::Widgets pybind11::qt pybind11::utils GTest::gmock)
2022-05-02 17:09:36 +02:00
target_include_directories(${target}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../mocks)
add_dependencies(python-tests ${target})
2022-05-02 17:09:36 +02:00
endforeach()