-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
50 lines (40 loc) · 1.33 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cmake_minimum_required(VERSION 3.10)
project(eventqueue VERSION 0.1.0)
option(ENABLE_TESTING "Enable compilation of unit tests" OFF)
option(BUILD_EXAMPLE "Enable compilation of example program" OFF)
add_library(eventqueue
"source/eventqueue.c"
"source/timer_heap.c"
"source/eq_time.c"
)
target_include_directories(eventqueue PUBLIC "${CMAKE_SOURCE_DIR}/include")
if (${ENABLE_TESTING})
enable_testing()
set(tests
timer_heap
eventqueue
)
set(timer_heap_sources
"tests/timer_heap_tests.c"
"source/timer_heap.c"
)
set(eventqueue_sources
"tests/eventqueue_tests.c"
"source/timer_heap.c"
"source/eventqueue.c"
"tests/mock_time.c"
)
foreach (test ${tests})
add_executable(${test}_tests ${${test}_sources})
target_include_directories(${test}_tests PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_options(${test}_tests PUBLIC -Wall -Wextra -Wpedantic)
add_test(NAME ${test}_tests COMMAND ${test}_tests)
add_test(NAME ${test}_memcheck
COMMAND valgrind --leak-check=full --error-exitcode=1 "${CMAKE_BINARY_DIR}/${test}_tests"
)
endforeach ()
endif ()
if (${BUILD_EXAMPLE})
add_executable(example "example/main.c")
target_link_libraries(example PUBLIC eventqueue)
endif ()