-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
51 lines (43 loc) · 2.17 KB
/
CMakeLists.txt
File metadata and controls
51 lines (43 loc) · 2.17 KB
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
cmake_minimum_required(VERSION 3.16)
project(iotspool VERSION 0.1.0 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
option(IOTSPOOL_BUILD_TESTS "Build test suite" ON)
option(IOTSPOOL_BUILD_EXAMPLES "Build host examples" ON)
option(IOTSPOOL_ENABLE_SHA256 "Enable SHA-256 support" ON)
# ── Warnings ────────────────────────────────────────────────────────────────
if(MSVC)
add_compile_options(/W4)
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
endif()
# ── Library ─────────────────────────────────────────────────────────────────
add_library(iotspool STATIC
src/spool.c
src/record.c
src/crc32.c
src/sha256.c
src/backoff.c
src/store_posix.c
)
target_include_directories(iotspool PUBLIC include)
target_include_directories(iotspool PRIVATE src)
if(MSVC)
target_compile_definitions(iotspool PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
if(IOTSPOOL_ENABLE_SHA256)
target_compile_definitions(iotspool PUBLIC IOTSPOOL_ENABLE_SHA256)
endif()
# ── Tests ────────────────────────────────────────────────────────────────────
if(IOTSPOOL_BUILD_TESTS)
enable_testing()
add_executable(iotspool_tests tests/test_main.c)
target_link_libraries(iotspool_tests PRIVATE iotspool)
target_include_directories(iotspool_tests PRIVATE src)
add_test(NAME iotspool_tests COMMAND iotspool_tests)
endif()
# ── Examples ─────────────────────────────────────────────────────────────────
if(IOTSPOOL_BUILD_EXAMPLES AND NOT WIN32)
add_executable(example_rpi examples/rpi/main.c)
target_link_libraries(example_rpi PRIVATE iotspool)
endif()