forked from secure-device-onboard/client-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (109 loc) · 3.05 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#
# Copyright 2020 Intel Corporation
# SPDX-License-Identifier: Apache 2.0
#
cmake_minimum_required(VERSION 3.10)
project(client_sdk)
set(BASE_DIR $ENV{PWD})
#set(CMAKE_VERBOSE_MAKEFILE ON)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(cmake/cli_input.cmake)
include(cmake/extension.cmake)
include(cmake/blob_path.cmake)
if (NOT(DEFINED ENV{SAFESTRING_ROOT}))
message(FATAL_ERROR "SAFESTING_ROOT not set")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/build)
set(CMAKE_BUILD_FILES_DIRECTORY ${BASE_DIR}/build)
set(CMAKE_BUILD_DIRECTORY ${BASE_DIR}/build)
set(CMAKE_BINARY_DIR ${BASE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${BASE_DIR}/build)
set(LIBRARY_OUTPUT_PATH ${BASE_DIR}/build)
set(APPLICATION_BINARY_DIR ${BASE_DIR}/build CACHE PATH "bin dir" )
client_sdk_compile_options(
-Wswitch-default
-Wunused-parameter
-Wsign-compare
-Wpedantic
-Werror
-Wimplicit-function-declaration
-Wnested-externs
-Wmissing-prototypes
-Wmissing-declarations
-Wdiscarded-qualifiers
-Wundef
-Wincompatible-pointer-types
-Wunused-function
-Wunused-variable
-Wstrict-prototypes
-Wshadow
-Wno-declaration-after-statement
-Wold-style-declaration
-Wold-style-definition
-Wall
)
client_sdk_compile_options(
-fstack-protector -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -fPIE -fPIC
)
if(${TARGET_OS} MATCHES linux)
# Safestring lib
client_sdk_include_directories(
$ENV{SAFESTRING_ROOT}/include
include
)
add_subdirectory(lib)
add_subdirectory(network)
add_subdirectory(storage)
add_subdirectory(crypto)
if (${MODULES} MATCHES true)
add_subdirectory(device_modules)
endif()
endif()
if(${TARGET_OS} MATCHES linux)
target_link_libraries(client_sdk client_sdk_interface)
add_executable(linux-client app/main.c)
target_sources(linux-client PRIVATE app/blob.c)
if(${CRYPTO_HW} MATCHES true)
target_sources(linux-client PRIVATE app/se_provisioning.c)
endif()
target_include_directories(linux-client PRIVATE app/include)
# Link all the individual static libs into one single executable
target_link_libraries(linux-client client_sdk network storage crypto)
client_sdk_ld_options(
-L$ENV{SAFESTRING_ROOT}/
-l:libsafestring.a
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
)
if (${TLS} STREQUAL openssl)
client_sdk_ld_options(
-Wl,--no-whole-archive -lssl -lcrypto -ldl
)
elseif(${TLS} MATCHES mbedtls)
client_sdk_ld_options(
-Wl,--no-whole-archive -lmbedcrypto
-Wl,--no-whole-archive -lmbedtls -lmbedx509
)
endif()
if( ${DA} MATCHES tpm)
client_sdk_ld_options(-ltss2-esys -ltss2-mu -ltss2-tctildr)
endif()
if (${CRYPTO_HW} MATCHES true)
client_sdk_ld_options(
-L$ENV{CRYPTOAUTHLIB_ROOT}/lib/
-l:libcryptoauth.so)
endif()
endif() ### target_os linux
# CLeanup of various files
# make pristine.
add_custom_target(
pristine
COMMAND
${CMAKE_COMMAND} -P ${BASE_DIR}/cmake/pristine.cmake
)
if (${unit-test} STREQUAL true)
add_subdirectory(tests/unit)
endif()
if(${TARGET_OS} STREQUAL mbedos)
add_subdirectory(mbedos)
endif()