Fix tests CMakeLists for MIGRATE_MODULE builds
- Top-level CMakeLists.txt: Skip tests subdirectory when MIGRATE_MODULE is set (tests require full codebase with cross-module dependencies) - tests/CMakeLists.txt: Add conditional checks for CodeGen and LtsTimelineClassic targets - Filter Grantlee tests BEFORE creating executable (fix order) - Exclude CodeGen tests when codegen_base target unavailable - Exclude LtsTimelineClassic tests when target unavailable - Make LtsTimelineClassic linking conditional with if(TARGET) This enables clean BUILD_RTI=OFF builds during incremental module migration with MIGRATE_MODULE flag.
This commit is contained in:
1 parent
92b7f26fc8
commit
f6c2ac04f9
2 files changed
+30
-6
No files matched your search
@@ -114,8 +114,12 @@ ENDIF()
|
||||
|
||||
ENABLE_TESTING()
|
||||
INCLUDE(CTest)
|
||||
# Add migration tests
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
# Add migration tests - skip when MIGRATE_MODULE targets specific Lts modules (tests need full codebase)
|
||||
if(NOT DEFINED MIGRATE_MODULE OR MIGRATE_MODULE STREQUAL "tests")
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
else()
|
||||
message(STATUS "MIGRATE_MODULE=${MIGRATE_MODULE} - skipping tests (need full codebase)")
|
||||
endif()
|
||||
CONFIGURE_FILE(CTestCustom.ctest ${CMAKE_BINARY_DIR}/CTestCustom.ctest COPYONLY)
|
||||
CONFIGURE_FILE(lts-cc.conf ${CMAKE_BINARY_DIR}/lts-cc.conf.distrib COPYONLY)
|
||||
|
||||
|
||||
@@ -36,6 +36,22 @@ if(BUILD_TESTING)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_.*Grantlee.*\\.cpp")
|
||||
message(STATUS "Migration tests: Grantlee support disabled (BUILD_GRANTLEE=OFF), excluded Grantlee tests")
|
||||
endif()
|
||||
|
||||
# Exclude CodeGen tests when CodeGen targets aren't available (MIGRATE_MODULE restricts scope)
|
||||
if(NOT TARGET codegen_base)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_StructBuilder\\.cpp")
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_SqlGenerator\\.cpp")
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_XmlReader\\.cpp")
|
||||
message(STATUS "Migration tests: CodeGen targets not available, excluded CodeGen tests")
|
||||
endif()
|
||||
|
||||
# Exclude LtsTimelineClassic tests when LtsTimelineClassic target isn't available
|
||||
if(NOT TARGET LtsTimelineClassic)
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_abstracttimelinemodel\\.cpp")
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_ltsclassicdatamodel\\.cpp")
|
||||
list(FILTER EXISTING_SOURCES EXCLUDE REGEX "test_ltsclassicfilterproxymodel\\.cpp")
|
||||
message(STATUS "Migration tests: LtsTimelineClassic target not available, excluded LtsTimelineClassic tests")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTING_SOURCES)
|
||||
message(WARNING "No migration test sources found after filtering - skipping migration_tests target")
|
||||
@@ -60,18 +76,22 @@ if(BUILD_TESTING)
|
||||
${CMAKE_BINARY_DIR}/Lts/Common/LtsTimeline
|
||||
)
|
||||
|
||||
# Link against Qt6 components and LtsTimelineClassic (provides export header)
|
||||
# Link against Qt6 components
|
||||
target_link_libraries(migration_tests PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Test
|
||||
GTest::gtest_main
|
||||
LtsTimelineClassic
|
||||
)
|
||||
|
||||
# Ensure LtsTimelineClassic is built before tests (generates export header)
|
||||
add_dependencies(migration_tests LtsTimelineClassic)
|
||||
# Link against LtsTimelineClassic only if it exists (may not exist with MIGRATE_MODULE)
|
||||
if(TARGET LtsTimelineClassic)
|
||||
target_link_libraries(migration_tests PRIVATE LtsTimelineClassic)
|
||||
add_dependencies(migration_tests LtsTimelineClassic)
|
||||
else()
|
||||
message(STATUS "LtsTimelineClassic target not available - skipping link (MIGRATE_MODULE may restrict scope)")
|
||||
endif()
|
||||
|
||||
# Grantlee tests require BUILD_GRANTLEE=ON
|
||||
if(BUILD_GRANTLEE)
|
||||
|
||||
Reference in new issue
Block a user