-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
115 lines (95 loc) · 2.61 KB
/
CMakeLists.txt
File metadata and controls
115 lines (95 loc) · 2.61 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
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
cmake_minimum_required(VERSION 3.16)
project(daa C)
set(CMAKE_C_STANDARD 99)
# Compiler options and definitions
add_compile_definitions(TPM_POSIX VERBOSE TPM_TPM20)
add_compile_options(
-Wall
-Wno-sign-compare
-Wno-comment
-Wno-unused-function
-Wno-write-strings
-O3
-v
-fexceptions
)
# AddressSanitizer and UndefinedBehaviorSanitizer options
option(DAA_ENABLE_ASAN "Enable AddressSanitizer" OFF)
option(DAA_ENABLE_UBSAN "Enable UBSanitizer" OFF)
if(DAA_ENABLE_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
if(DAA_ENABLE_UBSAN)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
# Prefer stricter warnings in development
add_compile_options(
-Wall -Wextra -Wpedantic
-Wshadow -Wpointer-arith -Wcast-qual -Wvla
)
# IBMTSS setup
if(NOT (TSS_INCLUDE_PATH AND TSS_LIB_PATH))
include(cmake/ibmtss.cmake)
list(APPEND DEPENDENCY_LIST "IBMTSS")
endif()
message(STATUS "IBMTSS_INCLUDE_PATH: ${TSS_INCLUDE_PATH}")
message(STATUS "IBMTSS_LIB_PATH: ${TSS_LIB_PATH}")
# mbedTLS setup
if(NOT (MBEDTLS_INCLUDE_PATH AND MBEDTLS_LIB_PATH))
include(cmake/mbedTLS.cmake)
list(APPEND DEPENDENCY_LIST "MBEDTLS")
endif()
message(STATUS "MBEDTLS_INCLUDE_PATH: ${MBEDTLS_INCLUDE_PATH}")
message(STATUS "MBEDTLS_LIB_PATH: ${MBEDTLS_LIB_PATH}")
# MIRACL Core setup
if(NOT (MIRACL_INCLUDE_PATH AND MIRACL_LIB_PATH))
include(cmake/core.cmake)
list(APPEND DEPENDENCY_LIST "MIRACL")
endif()
message(STATUS "MIRACL_INCLUDE_PATH: ${MIRACL_INCLUDE_PATH}")
message(STATUS "MIRACL_LIB_PATH: ${MIRACL_LIB_PATH}")
# Include and link directories
include_directories(
${TSS_INCLUDE_PATH}
${MBEDTLS_INCLUDE_PATH}
${MIRACL_INCLUDE_PATH}
)
link_directories(
${TSS_LIB_PATH}
${MBEDTLS_LIB_PATH}
${MIRACL_LIB_PATH}
)
# Source files
set(DAA_SOURCES
main.c
tpm_funcs.c tpm_funcs.h
templates.c templates.h
daa.c daa.h
issuer.c issuer.h
cryptoutils.c cryptoutils.h
defines.h
)
# Build target
add_executable(daa ${DAA_SOURCES})
# Link libraries
target_link_libraries(daa
ibmtss
${MIRACL_LIB_PATH}/core.a
mbedtls
mbedcrypto
Threads::Threads
)
# Editor hint: ensure include paths are visible to language servers
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
# Detect Mbed TLS version to guard MBEDTLS_PRIVATE usage
include(CheckIncludeFile)
check_include_file("mbedtls/version.h" HAVE_MBEDTLS_VERSION_H)
if(HAVE_MBEDTLS_VERSION_H)
add_compile_definitions(HAVE_MBEDTLS_VERSION_H)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Threads REQUIRED)