This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
211 lines (185 loc) · 4.62 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#
# DDS Security library
# Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
cmake_minimum_required(VERSION 3.5)
project("libddssec" VERSION 0.1.0 LANGUAGES C)
set(${PROJECT_NAME}_DESCRIPTION_SUMMARY "libddssec")
set(DSEC_CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules
CACHE INTERNAL "")
set(CMAKE_MODULE_PATH ${DSEC_CMAKE_MODULE_PATH})
message(STATUS
"${${PROJECT_NAME}_DESCRIPTION_SUMMARY} version ${PROJECT_VERSION}"
)
option(BUILD_TEST "Build tests" OFF)
option(BUILD_DOC "Build doxygen documentation" OFF)
# Toolchain options
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(COMPILE_OPTIONS
-Wall
-Wextra
-Werror
-Wno-missing-field-initializers
-Wno-unused-parameter
-Wfloat-equal
-Wformat-security
-Wformat-nonliteral
-Wformat-y2k
-Wmissing-declarations
-Wmissing-include-dirs
-Wmissing-noreturn
-Wnested-externs
-Wshadow
-Wstrict-prototypes
-Wswitch-default
-pedantic
-pedantic-errors
-shared
-fpic
-pipe
-fstack-protector-all
-fpie
-Wl,-pie
-Wl,-z,defs
-Wl,-z,now
-Wl,-z,relro
)
#
# Generate version header
#
set(version_header ${CMAKE_CURRENT_BINARY_DIR}/include/dsec_version.h)
message(STATUS "Generating version header in ${version_header}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/dsec_version.h.in
${version_header}
)
#
# Settings for OP-TEE
#
find_package(OPTEECLIENT REQUIRED)
#
# Source files
#
set(PROJECT_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/trusted_application/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
# Files from external libraries which need to be included in the source but
# which don't need to be checked for documentation.
set(EXTERNAL_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/src
)
set(PROJECT_SOURCE
src/dsec_ca.c
src/dsec_ih.c
src/dsec_ih_ca.c
src/dsec_ih_cert.c
src/dsec_ih_privkey.c
src/dsec_hh.c
src/dsec_hh_dh.c
src/dsec_ssh.c
src/dsec_hh_challenge.c
src/dsec_key_material.c
src/dsec_session_key.c
src/dsec_aes.c
)
set(DSEC_TA_UUID_STRING
"8ee919be-3954-4170-b4c2-da169f39536e"
CACHE INTERNAL "")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/util_function.cmake)
dsec_get_uuid_structure(${DSEC_TA_UUID_STRING} DSEC_TA_UUID_STRUCTURE)
list(APPEND COMPILE_DEFINITIONS
-DDSEC_TA_UUID=${DSEC_TA_UUID_STRUCTURE}
-DDSEC_TA_UUID_STRING="${DSEC_TA_UUID_STRING}"
)
#
# Trusted Application
#
add_subdirectory(trusted_application)
#
# Test support subdirectory
#
if(BUILD_TEST)
enable_testing()
add_subdirectory(tests)
endif()
#
# Documentation
#
if(BUILD_DOC)
add_subdirectory(doc)
endif()
#
# Library settings
#
add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCE})
target_link_libraries(${PROJECT_NAME}
PRIVATE
OPTEECLIENT::OPTEECLIENT
)
target_compile_options(${PROJECT_NAME} PRIVATE ${COMPILE_OPTIONS})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${COMPILE_DEFINITIONS})
target_include_directories(
${PROJECT_NAME}
PUBLIC
${PROJECT_INCLUDES}
PRIVATE
${EXTERNAL_INCLUDES}
)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/libddssec>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/trusted_application/include>
$<INSTALL_INTERFACE:include>
INTERFACE_LINK_LIBRARIES
${PROJECT_BINARY_DIR}/${PROJECT_NAME}.so
LINK_INTERFACE_LANGUAGES
C
CXX
COMPILE_DEFINITIONS
${COMPILE_DEFINITIONS}
COMPILE_OPTIONS
${COMPILE_OPTIONS}
IMPORTED_LINK_INTERFACE_LIBRARIES
OPTEECLIENT::OPTEECLIENT
PREFIX
""
)
install(
TARGETS
${PROJECT_NAME}
EXPORT
${PROJECT_NAME}
LIBRARY
DESTINATION lib
INCLUDES
DESTINATION include
PUBLIC_HEADER
DESTINATION include
)
# Generates and installs a CMake file containing code to import targets from the
# installation tree into another project. The generated file is
# ${PROJECT_NAME}.cmake (value specified in EXPORT)
install(
EXPORT
${PROJECT_NAME}
DESTINATION
lib/cmake/libddssec
COMPONENT
OPTEECLIENT::OPTEECLIENT
EXPORT_LINK_INTERFACE_LIBRARIES
)
export(
TARGETS
${PROJECT_NAME}
FILE
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake"
EXPORT_LINK_INTERFACE_LIBRARIES
)
add_library(arm::libddssec ALIAS ${PROJECT_NAME})