mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-21 09:45:37 -05:00
Fix/cmake test only build (#6709)
* fix(cmake): guard filter_string_test behind WITH_ORACLE or WITH_CLIENT. filter_string_test links against libcockatrice_filters, which is only built when WITH_ORACLE or WITH_CLIENT is enabled. Without this guard, test-only builds fail at configure time because the target doesn't exist. The guard condition mirrors the one in the root CMakeLists.txt that controls whether libcockatrice_filters is built. * fix(cmake): centralize TEST_QT_MODULES in FindQtRuntime.cmake Each test CMakeLists.txt was independently defining TEST_QT_MODULES with its own subset of Qt modules. This duplicated knowledge that already lives in FindQtRuntime.cmake (which handles module discovery for all other targets: SERVATRICE, COCKATRICE, ORACLE). Consolidate into a single definition using the union of all test requirements (Concurrent Network Svg Widgets), matching the existing pattern for application-target modules. This ensures test-only builds (-DTEST=ON without application targets) discover all necessary Qt components. * fix(cmake): guard libcockatrice_network behind application targets. libcockatrice_network is only needed by the client, server, and oracle targets. Other application-specific libraries (settings, models, filters) already have similar guards. This was an oversight that caused test-only builds to fail when network dependencies weren't available.
This commit is contained in:
parent
9bb399606c
commit
ce652de272
|
|
@ -254,7 +254,9 @@ endif()
|
|||
set(CPACK_PACKAGE_CONTACT "Zach Halpern <zach@cockatrice.us>")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_VENDOR "Cockatrice Development Team")
|
||||
set(CPACK_PACKAGE_DESCRIPTION "Cockatrice is an open-source, multiplatform application for playing tabletop card games over a network. The program's server design prevents users from manipulating the game for unfair advantage. The client also provides a single-player mode, which allows users to brew while offline.")
|
||||
set(CPACK_PACKAGE_DESCRIPTION
|
||||
"Cockatrice is an open-source, multiplatform application for playing tabletop card games over a network. The program's server design prevents users from manipulating the game for unfair advantage. The client also provides a single-player mode, which allows users to brew while offline."
|
||||
)
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
||||
|
|
@ -328,7 +330,12 @@ include(CPack)
|
|||
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_interfaces ${CMAKE_BINARY_DIR}/libcockatrice_interfaces)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_protocol ${CMAKE_BINARY_DIR}/libcockatrice_protocol)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_network ${CMAKE_BINARY_DIR}/libcockatrice_network)
|
||||
if(WITH_CLIENT
|
||||
OR WITH_SERVER
|
||||
OR WITH_ORACLE
|
||||
)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_network ${CMAKE_BINARY_DIR}/libcockatrice_network)
|
||||
endif()
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_deck_list ${CMAKE_BINARY_DIR}/libcockatrice_deck_list)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_rng ${CMAKE_BINARY_DIR}/libcockatrice_rng)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libcockatrice_card ${CMAKE_BINARY_DIR}/libcockatrice_card)
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
# ------------------------
|
||||
|
|
@ -30,23 +23,29 @@ add_test(NAME carddatabase_test COMMAND carddatabase_test)
|
|||
|
||||
# ------------------------
|
||||
# Filter String Test
|
||||
# (guard must match the condition for libcockatrice_filters in the root CMakeLists.txt)
|
||||
# ------------------------
|
||||
add_executable(filter_string_test ${MOCKS_SOURCES} ${VERSION_STRING_CPP} filter_string_test.cpp mocks.cpp)
|
||||
if(WITH_ORACLE OR WITH_CLIENT)
|
||||
add_executable(filter_string_test ${MOCKS_SOURCES} ${VERSION_STRING_CPP} filter_string_test.cpp mocks.cpp)
|
||||
|
||||
target_link_libraries(
|
||||
filter_string_test
|
||||
PRIVATE libcockatrice_filters
|
||||
PRIVATE Threads::Threads
|
||||
PRIVATE ${GTEST_BOTH_LIBRARIES}
|
||||
PRIVATE ${TEST_QT_MODULES}
|
||||
)
|
||||
target_link_libraries(
|
||||
filter_string_test
|
||||
PRIVATE libcockatrice_filters
|
||||
PRIVATE Threads::Threads
|
||||
PRIVATE ${GTEST_BOTH_LIBRARIES}
|
||||
PRIVATE ${TEST_QT_MODULES}
|
||||
)
|
||||
|
||||
add_test(NAME filter_string_test COMMAND filter_string_test)
|
||||
add_test(NAME filter_string_test COMMAND filter_string_test)
|
||||
|
||||
if(NOT GTEST_FOUND)
|
||||
add_dependencies(filter_string_test gtest)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ------------------------
|
||||
# Dependencies on gtest
|
||||
# ------------------------
|
||||
if(NOT GTEST_FOUND)
|
||||
add_dependencies(carddatabase_test gtest)
|
||||
add_dependencies(filter_string_test gtest)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user