-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
106 lines (92 loc) · 2.27 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 2.8)
project(mender C)
enable_testing()
# options
option(CODE_COVERAGE "Code Coverage" OFF)
option(ENABLE_TESTING "compile test code" OFF)
option(ENABLE_SANITIZER "enable sanitizer" OFF)
# sanitizer
if (ENABLE_SANITIZER MATCHES ON)
set(CMAKE_MODULE_PATH "${SANITIZER_DIR}/cmake" ${CMAKE_MODULE_PATH})
find_package(Sanitizers)
endif()
# Check for JSMN
include(CheckIncludeFile)
include(CheckCCompilerFlag)
add_definitions(
-DJSMN_STATIC
)
CHECK_INCLUDE_FILE("jsmn.h" HAVE_JSMN_H)
if (NOT HAVE_JSMN_H)
message( FATAL_ERROR "'jsmn.h' was not found" )
endif()
set(CMAKE_REQUIRED_LIBRARIES "-ljsmn")
CHECK_C_SOURCE_COMPILES("int main(void){return 0;}" HAVE_JSMN_LIB)
# global cflags
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Og -g")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_COVERAGE}")
add_compile_options(
-std=gnu99
-Wall
-Wextra
-Wshadow
-Wmissing-prototypes
-Wstrict-prototypes
-Wdeclaration-after-statement
-Werror
)
add_definitions(
-DMBEDTLS_DEPRECATED_WARNING
)
# global includes
include_directories(
include
)
add_definitions(
-DCONFIG_MENDER_MULTI_BUFFER_SZ=0x1000
-DCONFIG_MENDER_HTTP_RECV_BUFFER_SZ=128
)
if (ENABLE_TESTING MATCHES ON)
add_definitions(
-DMENDER_ENABLE_TESTING
-DCONFIG_MENDER_SEMVER
-DCONFIG_MENDER_SEMVER_PREVENT_ROLLBACK
)
add_subdirectory(tests)
endif()
# submodules
add_subdirectory(platform/linux)
add_subdirectory(platform/linux/test_tool)
# mender
add_library(mender
src/state.c
src/deployment_logger.c
src/mender.c
src/authmgr.c
src/client/client.c
src/client/client_auth.c
src/client/client_inventory.c
src/client/client_update.c
src/client/client_update_fetch.c
src/client/client_status.c
src/client/client_log.c
src/installer.c
src/installer_handlers.c
src/http.c
src/utils.c
src/stack.c
src/hexdump.c
$<$<BOOL:${ENABLE_TESTING}>:tests/mock_flags.c>
$<$<BOOL:${ENABLE_TESTING}>:tests/installer_test_data.c>
)
# sanitizer
if (ENABLE_SANITIZER MATCHES ON)
add_sanitizers(mender)
endif()
target_link_libraries(mender
mender_platform
http_parser
$<$<BOOL:${HAVE_JSMN_LIB}>:jsmn>
$<$<BOOL:${ENABLE_TESTING}>:cmocka>
)