feat: add tests configuration

This commit is contained in:
2025-06-21 22:11:01 +02:00
parent cfa52e9795
commit 3f005a2bbb
2 changed files with 74 additions and 8 deletions

View File

@@ -3,14 +3,18 @@ project(t3dsr C)
set(CMAKE_C_STANDARD 17)
# if microsoft compilation
if (MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic")
endif()
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.c)
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS src/*.h)
add_executable(main ${SOURCES} ${HEADERS})
add_executable(main ${SOURCES} ${HEADERS})
# ==== tests ====
enable_testing()
file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS tests/*.c)
list(FILTER SOURCES EXCLUDE REGEX ".*src/main\\.c$")
if(TEST_SOURCES)
add_executable(tests ${TEST_SOURCES} ${SOURCES})
add_test(NAME tests COMMAND tests)
endif()