forked from ladnir/cryptoTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
173 lines (129 loc) · 5.79 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
cmake_minimum_required (VERSION 3.18)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
project(cryptoTools VERSION 1.10.1)
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
############################################
# If top level cmake #
############################################
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
message("Please consider updating CMake to 3.12+")
endif()
# Set a default build type for single-configuration
# CMake generators if no build type is set.
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
endif()
if(MSVC)
# optionally add the following to CMAKE_PREFIX_PATH
if(NOT DEFINED CMAKE_PREFIX_PATH AND NOT DEFINED NO_OC_DEFAULT_PREFIX)
set(CMAKE_PREFIX_PATH
"c:/libs"
"${CMAKE_CURRENT_SOURCE_DIR}/.."
)
endif()
else()
# Select flags.
set(CMAKE_C_FLAGS "-Wall -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO " -O2 -g -ggdb")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb")
endif()
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
endif()
macro(EVAL var)
if(${ARGN})
set(${var} ON)
else()
set(${var} OFF)
endif()
endmacro()
if(DEFINED OC_PIC)
message("warning, setting ENABLE_PIC as OC_PIC = ${OC_PIC}")
set(ENABLE_PIC ${OC_PIC})
unset(OC_PIC CACHE)
endif()
#############################################
# CONFIGURE #
#############################################
option(ENABLE_SPAN_LITE "use the span-lite library" ON)
option(ENABLE_RELIC "use the relic library" OFF)
option(ENABLE_SODIUM "use libsodium" OFF)
option(ENABLE_CIRCUITS "compile the circuit module" OFF)
option(ENABLE_NET_LOG "compile with network logging" OFF)
option(ENABLE_WOLFSSL "compiler with WolfSSL enabled" OFF)
option(ENABLE_SSE "compile with SSE instructions" ON)
option(ENABLE_AVX "compile with AVX instructions" ${ENABLE_SSE})
option(ENABLE_BOOST "compile with BOOST networking integration" OFF)
option(ENABLE_OPENSSL "compile with OpenSSL networking integration" OFF)
option(ENABLE_ASAN "build with asan" OFF)
option(ENABLE_PIC "compile with -fPIC " OFF)
option(VERBOSE_FETCH "" ON)
if(NOT DEFINED CRYPTO_TOOLS_STD_VER)
set(CRYPTO_TOOLS_STD_VER 14)
endif()
if(NOT ENABLE_SSE)
message("AVX requires SSE to be enabled.")
set(ENABLE_AVX OFF)
endif()
option(FETCH_AUTO "automatically download and build dependencies" OFF)
#option(FETCH_SPAN_LITE "download and build span" OFF))
EVAL(FETCH_SPAN_LITE_IMPL
(DEFINED FETCH_SPAN_LITE AND FETCH_SPAN_LITE) OR
((NOT DEFINED FETCH_SPAN_LITE) AND (FETCH_AUTO AND ENABLE_SPAN_LITE)))
#option(FETCH_RELIC "download and build Relic" OFF))
EVAL(FETCH_RELIC_IMPL
(DEFINED FETCH_RELIC AND FETCH_RELIC) OR
((NOT DEFINED FETCH_RELIC) AND (FETCH_AUTO AND ENABLE_RELIC)))
#option(FETCH_SODIUM "download and build Sodium" OFF))
EVAL(FETCH_SODIUM_IMPL
(DEFINED FETCH_SODIUM AND FETCH_SODIUM) OR
((NOT DEFINED FETCH_SODIUM) AND (FETCH_AUTO AND ENABLE_SODIUM)))
#option(FETCH_BOOST "download and build Boost" OFF))
EVAL(FETCH_BOOST_IMPL
(DEFINED FETCH_BOOST AND FETCH_BOOST) OR
((NOT DEFINED FETCH_BOOST) AND (FETCH_AUTO AND ENABLE_BOOST)))
if(ENABLE_BOOST)
set(ENABLE_COPROTO true)
endif()
#option(FETCH_BOOST "download and build Boost" OFF))
EVAL(FETCH_COPROTO_IMPL
(DEFINED FETCH_COPROTO AND FETCH_COPROTO) OR
((NOT DEFINED FETCH_COPROTO) AND (FETCH_AUTO AND ENABLE_COPROTO)))
EVAL(FETCH_LIBDIVIDE_IMPL
(DEFINED FETCH_LIBDIVIDE AND FETCH_LIBDIVIDE) OR
((NOT DEFINED FETCH_LIBDIVIDE) AND (FETCH_AUTO)))
option(VERBOSE_FETCH "Print build info for fetched libraries" ON)
message(STATUS "cryptoTools options\n=======================================================")
message(STATUS "Option: CRYPTO_TOOLS_STD_VER = ${CRYPTO_TOOLS_STD_VER}\n")
message(STATUS "Option: NO_SYSTEM_PATH = ${NO_SYSTEM_PATH}")
message(STATUS "Option: FETCH_AUTO = ${FETCH_AUTO}")
message(STATUS "Option: VERBOSE_FETCH = ${VERBOSE_FETCH}\n")
message(STATUS "Option: FETCH_RELIC = ${FETCH_RELIC}")
message(STATUS "Option: FETCH_SODIUM = ${FETCH_SODIUM}")
message(STATUS "Option: FETCH_BOOST = ${FETCH_BOOST}")
message(STATUS "Option: FETCH_COPROTO = ${FETCH_COPROTO}")
message(STATUS "Option: FETCH_LIBDIVIDE = ${FETCH_LIBDIVIDE_IMPL}\n")
message(STATUS "Option: CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}\n\tRelease\n\tDebug\n\tRelWithDebInfo")
message(STATUS "Option: ENABLE_SPAN_LITE = ${ENABLE_SPAN_LITE}")
message(STATUS "Option: ENABLE_RELIC = ${ENABLE_RELIC}")
message(STATUS "Option: ENABLE_SODIUM = ${ENABLE_SODIUM}")
message(STATUS "Option: ENABLE_BOOST = ${ENABLE_BOOST}")
message(STATUS "Option: ENABLE_OPENSSL = ${ENABLE_OPENSSL}")
message(STATUS "Option: ENABLE_COPROTO = ${ENABLE_COPROTO}")
message(STATUS "Option: ENABLE_CIRCUITS = ${ENABLE_CIRCUITS}")
message(STATUS "Option: ENABLE_SSE = ${ENABLE_SSE}")
message(STATUS "Option: ENABLE_AVX = ${ENABLE_AVX}")
message(STATUS "Option: ENABLE_PIC = ${ENABLE_PIC}")
message(STATUS "Option: ENABLE_ASAN = ${ENABLE_ASAN}\n\n")
#############################################
# cryptoTools, tests, frontend #
#############################################
include("${CMAKE_CURRENT_LIST_DIR}/cmake/cryptoToolsDepHelper.cmake")
add_subdirectory(cryptoTools)
add_subdirectory(tests_cryptoTools)
add_subdirectory(frontend_cryptoTools)
configure_file(cryptoTools/Common/config.h.in "cryptoTools/Common/config.h" )
include("cmake/install.cmake")