diff --git a/cmake/FindQtRuntime.cmake b/cmake/FindQtRuntime.cmake index c205ebdcf..42060c835 100644 --- a/cmake/FindQtRuntime.cmake +++ b/cmake/FindQtRuntime.cmake @@ -29,7 +29,9 @@ if(WITH_ORACLE) set(_ORACLE_NEEDED Concurrent Network Svg Widgets) endif() if(TEST) - set(_TEST_NEEDED Widgets) + # Union of Qt modules required across all test targets (independent of application targets). + # When adding a new test that needs additional Qt modules, add them here rather than in the test's CMakeLists.txt. + set(_TEST_NEEDED Concurrent Network Svg Widgets) endif() set(REQUIRED_QT_COMPONENTS ${REQUIRED_QT_COMPONENTS} ${_SERVATRICE_NEEDED} ${_COCKATRICE_NEEDED} ${_ORACLE_NEEDED} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d80ccce4f..c20973436 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,5 @@ +# NOTE: Qt modules for tests are defined centrally in cmake/FindQtRuntime.cmake (the _TEST_NEEDED variable). +# If a new test needs additional Qt modules, add them there — not in individual test CMakeLists.txt files. enable_testing() add_test(NAME dummy_test COMMAND dummy_test) diff --git a/tests/carddatabase/CMakeLists.txt b/tests/carddatabase/CMakeLists.txt index 2eb835a26..987e23cd5 100644 --- a/tests/carddatabase/CMakeLists.txt +++ b/tests/carddatabase/CMakeLists.txt @@ -6,13 +6,6 @@ project(CardDatabaseTests VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MI # ------------------------ add_definitions("-DCARDDB_DATADIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"") -# ------------------------ -# Qt modules -# ------------------------ -set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Concurrent ${COCKATRICE_QT_VERSION_NAME}::Network - ${COCKATRICE_QT_VERSION_NAME}::Widgets ${COCKATRICE_QT_VERSION_NAME}::Svg -) - # ------------------------ # Card Database Test # ------------------------ diff --git a/tests/loading_from_clipboard/CMakeLists.txt b/tests/loading_from_clipboard/CMakeLists.txt index 85133a8e8..719d62f45 100644 --- a/tests/loading_from_clipboard/CMakeLists.txt +++ b/tests/loading_from_clipboard/CMakeLists.txt @@ -5,10 +5,6 @@ if(NOT GTEST_FOUND) add_dependencies(loading_from_clipboard_test gtest) endif() -set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Concurrent ${COCKATRICE_QT_VERSION_NAME}::Network - ${COCKATRICE_QT_VERSION_NAME}::Widgets -) - target_link_libraries( loading_from_clipboard_test libcockatrice_deck_list libcockatrice_card Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES} diff --git a/tests/oracle/CMakeLists.txt b/tests/oracle/CMakeLists.txt index b89663d6f..c5c1e9097 100644 --- a/tests/oracle/CMakeLists.txt +++ b/tests/oracle/CMakeLists.txt @@ -4,8 +4,6 @@ if(NOT GTEST_FOUND) add_dependencies(parse_cipt_test gtest) endif() -set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Widgets) - target_link_libraries(parse_cipt_test Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES}) add_test(NAME parse_cipt_test COMMAND parse_cipt_test)