-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
211 lines (181 loc) · 6.4 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
211
# Copyright (c) 2022 Haofan Zheng
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
cmake_minimum_required(VERSION 3.18)
project(DecentEthereum LANGUAGES C CXX VERSION 0.0.1)
################################################################################
# Set compile options
################################################################################
if(MSVC)
set(COMMON_OPTIONS /W4 /WX /EHsc /MP /GR /Zc:__cplusplus
/wd4815 # Mitigate issue in SGXSDK about zero-sized array
/wd4310 # Mitigate issue in SGXSDK about cast truncates in #include <limits>
)
set(DEBUG_OPTIONS /MTd /Od /Zi /DDEBUG)
set(RELEASE_OPTIONS /MT /Ox /Oi /Ob2 /fp:fast)# /DNDEBUG
# set(CMAKE_EXE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG)
else()
set(COMMON_OPTIONS -pthread -Wall -Wextra -Werror)
set(DEBUG_OPTIONS -O0 -g -DDEBUG)
set(RELEASE_OPTIONS -O2) #-DNDEBUG defined by default
endif()
set(DEBUG_OPTIONS ${COMMON_OPTIONS} ${DEBUG_OPTIONS})
set(RELEASE_OPTIONS ${COMMON_OPTIONS} ${RELEASE_OPTIONS})
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
endif()
################################################################################
# Setup CMake environment for enclave targets
################################################################################
#Removed Basic Runtime Checks in MSVC
if(MSVC)
STRING (REGEX REPLACE "/RTC(su|[1su])" ""
CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
STRING (REGEX REPLACE "/RTC(su|[1su])" ""
CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
STRING (REGEX REPLACE "/RTC(su|[1su])" ""
CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
STRING (REGEX REPLACE "/RTC(su|[1su])" ""
CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
endif()
#Remove all standard libraries dependency here so that enclave DLL can be
# compiled properly. And it will be added back later for non-enclave apps.
set(UNTRUSTED_CXX_STANDARD_LIBRARIES ${CMAKE_CXX_STANDARD_LIBRARIES_INIT})
set(UNTRUSTED_C_STANDARD_LIBRARIES ${CMAKE_C_STANDARD_LIBRARIES_INIT})
set(CMAKE_CXX_STANDARD_LIBRARIES "")
set(CMAKE_C_STANDARD_LIBRARIES "")
# Add DebugSimulation to CMake configuration types
set(CMAKE_CONFIGURATION_TYPES Release Debug DebugSimulation)
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug DebugSimulation)
set(CMAKE_CXX_FLAGS_DEBUGSIMULATION ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUGSIMULATION ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS_DEBUGSIMULATION ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
set(CMAKE_SHARED_LINKER_FLAGS_DEBUGSIMULATION ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
set(CMAKE_STATIC_LINKER_FLAGS_DEBUGSIMULATION ${CMAKE_STATIC_LINKER_FLAGS_DEBUG})
################################################################################
# Fetch external dependencies
################################################################################
include(FetchContent)
## SimpleCMakeScripts
FetchContent_Declare(
git_simplecmakescripts
GIT_REPOSITORY https://github.com/zhenghaven/SimpleCMakeScripts.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simplecmakescripts)
simplecmakescripts_enable()
## SimpleUtf
FetchContent_Declare(
git_simpleutf
GIT_REPOSITORY https://github.com/zhenghaven/SimpleUtf.git
GIT_TAG main
)
FetchContent_MakeAvailable(git_simpleutf)
## SimpleObjects
FetchContent_Declare(
git_simpleobjects
GIT_REPOSITORY https://github.com/zhenghaven/SimpleObjects.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simpleobjects)
## SimpleRlp
FetchContent_Declare(
git_simplerlp
GIT_REPOSITORY https://github.com/zhenghaven/SimpleRlp.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simplerlp)
## SimpleJson
FetchContent_Declare(
git_simplejson
GIT_REPOSITORY https://github.com/zhenghaven/SimpleJson.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simplejson)
## SimpleSysIO
FetchContent_Declare(
git_simplesysio
GIT_REPOSITORY https://github.com/zhenghaven/SimpleSysIO.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simplesysio)
## SimpleConcurrency
FetchContent_Declare(
git_simpleconcurrency
GIT_REPOSITORY https://github.com/zhenghaven/SimpleConcurrency.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simpleconcurrency)
## SimpleBoostSelector
set(SIMPLEBOOST_BOOST_VER 1.81.0 CACHE STRING "Boost version to use." FORCE)
FetchContent_Declare(
git_simpleboostselector
GIT_REPOSITORY https://github.com/zhenghaven/SimpleBoostSelector.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_simpleboostselector)
simpleboost_enable_sublib(asio)
## EclipseMonitor
FetchContent_Declare(
git_eclipsemonitor
GIT_REPOSITORY https://github.com/zhenghaven/EclipseMonitor.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_eclipsemonitor)
## DecentEnclave
FetchContent_Declare(
git_decentenclave
GIT_REPOSITORY https://github.com/zhenghaven/DecentEnclave.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_decentenclave)
## mbedTLScpp
FetchContent_Declare(
git_mbedtlscpp
GIT_REPOSITORY https://github.com/zhenghaven/mbedTLScpp.git
GIT_TAG dev
)
FetchContent_MakeAvailable(git_mbedtlscpp)
## MbedTLS
set(ENABLE_TESTING OFF CACHE BOOL "Build mbed TLS tests." FORCE)
set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbed TLS programs." FORCE)
if (MSVC)
set(
MSVC_STATIC_RUNTIME
ON
CACHE BOOL
"Build the libraries with /MT compiler flag"
FORCE
)
endif()
FetchContent_Declare(
git_mbedtls
GIT_REPOSITORY https://github.com/zhenghaven/mbedtls.git
GIT_TAG decent-enclave-v3.5.2
)
FetchContent_MakeAvailable(git_mbedtls)
mbedTLScpp_Decentize_Normal(mbedcrypto)
mbedTLScpp_Decentize_Normal(mbedx509)
mbedTLScpp_Decentize_Normal(mbedtls)
mbedTLScpp_Decentize_Enclave(mbedcrypto_enclave)
mbedTLScpp_Decentize_Enclave(mbedx509_enclave)
mbedTLScpp_Decentize_Enclave(mbedtls_enclave)
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_DIR}/include/)
set(MBEDCRYPTO_LIBRARY mbedcrypto)
set(MBEDX509_LIBRARY mbedx509)
set(MBEDTLS_LIBRARY mbedtls)
## curl
include(SimpleCUrlConfig)
simple_curl_https_pre_configuration()
FetchContent_Declare(
git_curl
GIT_REPOSITORY https://github.com/curl/curl.git
GIT_TAG curl-7_86_0
)
FetchContent_MakeAvailable(git_curl)
################################################################################
# Add source directories
################################################################################
add_subdirectory(src)
add_subdirectory(tests)