-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
123 lines (104 loc) · 3.61 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
# CMake requirements
cmake_minimum_required (VERSION 3.13)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Generic library information
project (libgroupsig)
set (libgroupsig_VERSION_MAJOR 1)
set (libgroupsig_VERSION_MINOR 0)
set (libgroupsig_VERSION_PATCH 0)
# Set the paths for produced libraries and runtime binaries
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# Global compiler flags
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -fPIC")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -fPIC")
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif ()
# If -DSHA2 present, use SHA2 in PS16 (original is BLAKE)
if (SHA2)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSHA2")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSHA2")
endif ()
# If -DSHA3 present, use SHA3 in PS16/KTY04
if (SHA3)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSHA3")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSHA3")
endif ()
# If -DHW3 present, then pass -DHW3 to gcc (only affects if -DHW present too)
if (HW3)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHW3")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHW3")
endif ()
add_link_options("LINKER:--allow-multiple-definition")
# Add the binary tree to the search path for include files
include_directories("${CMAKE_SOURCE_DIR}/src")
include_directories("${CMAKE_SOURCE_DIR}/src/include")
# Compiler headers path for mcl
include_directories("${CMAKE_BINARY_DIR}/external/include")
# Compiler library path for mcl
link_directories("${CMAKE_BINARY_DIR}/external/lib")
# Check dependencies
## OpenSSL
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(OPENSSL_ROOT_DIR /home/xilinx/openssl-3.0.2)
include(FindOpenSSL)
endif ()
find_package(OpenSSL REQUIRED)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
include_directories(${OPENSSL_INCLUDE_DIR})
link_directories(/home/xilinx/openssl-3.0.2)
endif ()
# Add modules
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
## Configure options
option (
USE_GTEST
"Build with GoogleTest for testing.")
option (
USE_GCOV
"Build with GCov for coverage reporting.")
option (
USE_MCL
"Build a local version of MCL for pairing based crypto."
ON)
## Google Test
if (USE_GTEST)
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -fprofile-arcs -ftest-coverage")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_TEST_COMPILE_FLAGS}" )
include (gtest)
endif (USE_GTEST)
## GCOV
if (USE_GCOV)
include (gcovr)
endif (USE_GCOV)
## MCL
if (USE_MCL)
include (mcl)
# link_directories("${CMAKE_BINARY_DIR}/external/kk/lib")
else ()
find_package (MCL REQUIRED)
include_directories(${MCL_INCLUDE_DIRS})
endif (USE_MCL)
## @TODO Is this needed/used?
## CTest
include (CTest)
# Subdirectories
add_subdirectory (${CMAKE_SOURCE_DIR}/src/logger)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/msg)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/sys)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/shim)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/crypto)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/math)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/misc)
# if -DHW present, then load src/hw code
if (HW)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/hw)
endif ()
add_subdirectory (${CMAKE_SOURCE_DIR}/src/groupsig)
add_subdirectory (${PROJECT_SOURCE_DIR}/src/tools)
add_subdirectory (${CMAKE_SOURCE_DIR}/src/test/basic)