50 lines
2.1 KiB
CMake
50 lines
2.1 KiB
CMake
include(${CMAKE_SOURCE_DIR}/cmake/VoidTesting.cmake)
|
|
|
|
get_property(ACTIVE_MODULES GLOBAL PROPERTY VOID_MODULES)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# PART 1: Internal kitchen-sink test (links every module).
|
|
# ------------------------------------------------------------------------------
|
|
file(GLOB_RECURSE INTERNAL_SOURCES CONFIGURE_DEPENDS "internal/*.cpp")
|
|
|
|
if(INTERNAL_SOURCES)
|
|
add_executable(VoidInternalTests ${INTERNAL_SOURCES})
|
|
target_link_libraries(VoidInternalTests PRIVATE Void::Testing)
|
|
foreach(mod ${ACTIVE_MODULES})
|
|
if(NOT mod STREQUAL "Testing" AND NOT mod STREQUAL "TestingMock")
|
|
target_link_libraries(VoidInternalTests PRIVATE Void::${mod})
|
|
endif()
|
|
endforeach()
|
|
if(TARGET Void::TestingMock)
|
|
target_link_libraries(VoidInternalTests PRIVATE Void::TestingMock)
|
|
endif()
|
|
add_test(NAME internal COMMAND VoidInternalTests --no-color)
|
|
endif()
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# PART 2: Standalone tests — one executable per source file under
|
|
# tests/standalone/<Module>/. Auto-scan picks each one up via the deferred
|
|
# sweep registered by cmake/VoidTesting.cmake.
|
|
# ------------------------------------------------------------------------------
|
|
foreach(mod ${ACTIVE_MODULES})
|
|
set(STANDALONE_MOD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/standalone/${mod}")
|
|
|
|
if(IS_DIRECTORY ${STANDALONE_MOD_DIR})
|
|
file(GLOB test_files CONFIGURE_DEPENDS "${STANDALONE_MOD_DIR}/*.cpp")
|
|
|
|
foreach(test_src ${test_files})
|
|
get_filename_component(test_file_name ${test_src} NAME_WE)
|
|
set(EXE_NAME "test_standalone_${mod}_${test_file_name}")
|
|
|
|
add_executable(${EXE_NAME} ${test_src})
|
|
target_link_libraries(${EXE_NAME} PRIVATE Void::Testing)
|
|
if(NOT mod STREQUAL "Testing" AND NOT mod STREQUAL "TestingMock")
|
|
target_link_libraries(${EXE_NAME} PRIVATE Void::${mod})
|
|
endif()
|
|
if(TARGET Void::TestingMock)
|
|
target_link_libraries(${EXE_NAME} PRIVATE Void::TestingMock)
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
endforeach()
|