cmake_minimum_required(VERSION 4.0) # Enable testing enable_testing() # Find Qt packages for tests find_package(Qt6 COMPONENTS Core Gui Widgets Multimedia Test REQUIRED) # Add test executables - link to static library instead of compiling sources add_executable(test_item unit/items/test_item.cpp) add_executable(test_sensor unit/sensors/test_sensor.cpp) add_executable(test_actor unit/actors/test_actor.cpp) add_executable(test_itemstore unit/items/test_itemstore.cpp) add_executable(test_itemloadersource unit/items/test_itemloadersource.cpp) add_executable(test_mqttitem unit/items/test_mqttitem.cpp) add_executable(test_tcp unit/service/test_tcp.cpp) # Link all tests to static library foreach(test test_item test_sensor test_actor test_itemstore test_itemloadersource test_mqttitem test_tcp) target_link_libraries(${test} smartvos_core Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Multimedia Qt6::Network Qt6::WebSockets Qt6::Mqtt Qt6::Test ) # Include paths - the static library already has the correct include paths target_include_directories(${test} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ${Qt6Gui_PRIVATE_INCLUDE_DIRS} ) endforeach() # Add tests to CTest add_test(NAME test_item COMMAND test_item) add_test(NAME test_sensor COMMAND test_sensor) add_test(NAME test_actor COMMAND test_actor) add_test(NAME test_itemstore COMMAND test_itemstore) add_test(NAME test_itemloadersource COMMAND test_itemloadersource) add_test(NAME test_mqttitem COMMAND test_mqttitem) add_test(NAME test_tcp COMMAND test_tcp)