mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-21 17:55:21 -05:00
* 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.
52 lines
1.5 KiB
CMake
52 lines
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(CardDatabaseTests VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
|
|
|
# ------------------------
|
|
# Definitions
|
|
# ------------------------
|
|
add_definitions("-DCARDDB_DATADIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data/\"")
|
|
|
|
# ------------------------
|
|
# Card Database Test
|
|
# ------------------------
|
|
add_executable(carddatabase_test ${MOCKS_SOURCES} ${VERSION_STRING_CPP} carddatabase_test.cpp mocks.cpp)
|
|
|
|
target_link_libraries(
|
|
carddatabase_test
|
|
PRIVATE libcockatrice_card
|
|
PRIVATE Threads::Threads
|
|
PRIVATE ${GTEST_BOTH_LIBRARIES}
|
|
PRIVATE ${TEST_QT_MODULES}
|
|
)
|
|
|
|
add_test(NAME carddatabase_test COMMAND carddatabase_test)
|
|
|
|
# ------------------------
|
|
# Filter String Test
|
|
# (guard must match the condition for libcockatrice_filters in the root CMakeLists.txt)
|
|
# ------------------------
|
|
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}
|
|
)
|
|
|
|
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)
|
|
endif()
|