-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
59 lines (45 loc) · 1.66 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
51
52
53
54
55
56
57
58
59
cmake_minimum_required(VERSION 3.22)
set(AVAILABLE_TESTS
interrupt_latency
malloc_free
message_queue
mutex_lock_unlock
sem_context_switch
sem_signal_release
thread_switch_yield
thread)
set(AVAILABLE_RTOSES
zephyr
freertos)
set(ITERATIONS 10000 CACHE STRING "Number of iterations for each test")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DITERATIONS=${ITERATIONS}")
set(CALIBRATION_LOOPS 10000 CACHE STRING "Number of calibration loops for each test")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCALIBRATION_LOOPS=${CALIBRATION_LOOPS}")
if (NOT RTOS IN_LIST AVAILABLE_RTOSES)
message(FATAL_ERROR "Choose either [zephyr] or [freertos]")
endif()
# Add include directory for bench_api.h and bench_utils.h
include_directories(h)
# Include any ${RTOS} specific build rules
include(src/${RTOS}/${RTOS}.cmake)
add_subdirectory(src/${RTOS})
project(bench)
list(LENGTH TEST tests_to_run)
if (${tests_to_run} EQUAL 0)
list(TRANSFORM AVAILABLE_TESTS REPLACE "(.+)" "src/common/bench_\\1_test.c" OUTPUT_VARIABLE sources)
target_sources(app PRIVATE ${sources})
target_sources(app PRIVATE src/common/bench_utils.c)
target_sources(app PRIVATE src/common/bench_all.c)
return()
endif()
if(NOT ${tests_to_run} EQUAL 1)
message(FATAL_ERROR "Choose exactly one test")
endif()
if (NOT ${TEST} IN_LIST AVAILABLE_TESTS)
list(JOIN AVAILABLE_TESTS "\n" pretty_print)
message(FATAL_ERROR "Choose one test from:\n${pretty_print}")
endif()
string(TOUPPER ${TEST} test_upper)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DRUN_${test_upper}")
target_sources(app PRIVATE src/common/bench_utils.c)
target_sources(app PRIVATE src/common/bench_${TEST}_test.c)