summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-08-20 16:04:41 +0000
committerpeter <peter@pmikkelsen.com>2026-08-20 16:04:41 +0000
commit3be992e3f45dcfd9f8a45fa447de3abb710819b7 (patch)
tree6cf02c89acdb0fbf12c20f03ea190a0047221db9 /CMakeLists.txt
parent3a81615601bf37ffc4f7b570030709ac0782e2ed (diff)
Adapt a different coding style (no typedef'ed structs, C90...), and start working on a test setup.
FossilOrigin-Name: ebb73df5fc58859b6e985c5ec84196bdd09f639dbcdc69e706f6b17652a2d413
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt30
1 files changed, 29 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29f567b..73d2a62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ project(aplwc
LANGUAGES C
)
-set(CMAKE_C_STANDARD 99)
+set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
@@ -15,17 +15,35 @@ target_include_directories(common INTERFACE
)
target_compile_options(common INTERFACE
$<$<CONFIG:Debug>:
+ -O0
-Wall
-Wextra
-Wpedantic
-Werror
-fsanitize=address,undefined
+ -DAPLWC_BUILD_TYPE_DEBUG
+ >
+
+ $<$<CONFIG:Coverage>:
+ -O0
+ --coverage
+ -fcondition-coverage
+ -DAPLWC_BUILD_TYPE_COVERAGE
+ >
+
+ $<$<CONFIG:Release>:
+ -DAPLWC_BUILD_TYPE_RELEASE
>
)
target_link_options(common INTERFACE
$<$<CONFIG:Debug>:
-fsanitize=address,undefined
>
+
+ $<$<CONFIG:Coverage>:
+ --coverage
+ -fcondition-coverage
+ >
)
add_library(aplwc
@@ -39,3 +57,13 @@ add_executable(aplwc-repl
src/main.c
)
target_link_libraries(aplwc-repl PRIVATE common aplwc)
+
+enable_testing()
+file(GLOB TEST_SOURCES CONFIGURE_DEPENDS "tests/*.c")
+foreach(source ${TEST_SOURCES})
+ get_filename_component(name "${source}" NAME_WE)
+ set(test_bin "testbin-${name}")
+ add_executable("${test_bin}" "${source}")
+ target_link_libraries("${test_bin}" PRIVATE common aplwc)
+ add_test(NAME "${name}" COMMAND "${test_bin}")
+endforeach()