Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/tests/CMakeLists.txt
T

79 lines
2.6 KiB
CMake

# CMakeLists.txt für Qt6-Migrationstests
# Diese Tests validieren BUILD_RTI Guards, Qt6-Kompatibilität und RTI-Integration
cmake_minimum_required(VERSION 3.16)
# Qt6 finden (wird vom Hauptprojekt gesetzt, aber sicherheitshalber hier auch)
find_package(Qt6 REQUIRED COMPONENTS Core Test)
# Try to find system-wide GTest first, fallback to FetchContent
find_package(GTest QUIET)
if(NOT TARGET GTest::gtest_main)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.13.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
# Nur bauen wenn BUILD_TESTING aktiviert ist
if(BUILD_TESTING)
# Collect all test source files
set(MIGRATION_TEST_SOURCES
test_build_rti_guards.cpp
test_qt6_compatibility.cpp
test_saa_telegrams.cpp
test_rti_integration.cpp
)
# Check which files actually exist
set(EXISTING_SOURCES "")
foreach(src ${MIGRATION_TEST_SOURCES})
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
list(APPEND EXISTING_SOURCES "${src}")
endif()
endforeach()
if(EXISTING_SOURCES)
add_executable(migration_tests ${EXISTING_SOURCES})
target_compile_features(migration_tests PRIVATE cxx_std_23)
target_include_directories(migration_tests PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/include
)
# Link against Qt6 components
target_link_libraries(migration_tests PRIVATE
Qt6::Core
Qt6::Test
GTest::gtest_main
)
# RTI libraries if BUILD_RTI is ON
if(BUILD_RTI)
find_package(RTI QUIET)
if(RTI_FOUND)
target_include_directories(migration_tests PRIVATE ${RTI_INCLUDE_DIRS})
target_link_libraries(migration_tests PRIVATE ${RTI_LIBRARIES})
target_compile_definitions(migration_tests PRIVATE BUILD_RTI=1)
message(STATUS "RTI found: ${RTI_LIBRARIES}")
else()
message(STATUS "BUILD_RTI=ON but RTI not found - building tests without RTI")
endif()
endif()
# Register with CTest
include(GoogleTest)
gtest_discover_tests(migration_tests)
message(STATUS "Migration tests enabled: ${EXISTING_SOURCES}")
else()
message(WARNING "No migration test sources found in ${CMAKE_CURRENT_SOURCE_DIR}")
endif()
endif()