-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (118 loc) · 4.95 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
cmake_minimum_required(VERSION 3.12)
project(SecureLocal LANGUAGES CXX)
# YouCompleteMe
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
execute_process(COMMAND ln -s ln -s build/compile_commands.json ./ )
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message(FATAL_ERROR "requires at least g++-8")
endif()
#set (CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -fno-omit-frame-pointer")
# Add sanitizer flags for C++ compiler for "Debug" configuration
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address,undefined")
# Set build type to `Release` if non was specified:
# (cf. https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-change-the-default-build-mode-and-see-it-reflected-in-the-gui)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Write built executables and libraries to bin/ and lib/, respectively.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(extern/ABY)
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
# To used an opencv version installed in build
# You might need to do this first???
#set(OpenCV_DIR ${CMAKE_CURRENT_BINARY_DIR})
#set(BUILD_SHARED_LIBS OFF)
#add_subdirectory(extern/opencv)
#set(INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/")
#find_package(OpenCV REQUIRED)
#add_library(opencv INTERFACE)
#include_directories(${OpenCV_INCLUDE_DIRS})
# To use the version installed on the system
#find_package(opencv4 QUIET)
execute_process(COMMAND mkdir build
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/opencv/")
execute_process(COMMAND cmake ..
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/opencv/build")
execute_process(COMMAND make -j16
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/opencv/build")
execute_process(COMMAND sudo make install
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/opencv/build")
set(OpenCV_DIR "")
find_package(OpenCV REQUIRED)
#include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "cv libs: ${OpenCV_LIBS}")
message(STATUS "include_path: ${OpenCV_INCLUDE_DIRS}")
foreach(empdir tool ot sh2pc)
# execute_process(COMMAND rm -rf build/
# WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
# execute_process(COMMAND rm -rf CMakeCache.txt
# WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
# execute_process(COMMAND make clean
# WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
execute_process(COMMAND cmake -DENABLE_FLOAT=On -DTHREADING=On .
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
execute_process(COMMAND make -j16
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
execute_process(COMMAND sudo make install
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
find_package(emp-tool REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-${empdir}")
endforeach()
find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(emp-tool REQUIRED)
find_package(emp-ot REQUIRED)
find_package(emp-sh2pc REQUIRED)
#find_package(GMP REQUIRED)
include(${CMAKE_CURRENT_SOURCE_DIR}/extern/emp-sh2pc/cmake/emp-sh2pc-config.cmake)
# turn on threading for this code b/c it's turned on for emp
ADD_DEFINITIONS(-DTHREADING)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/extern/Catch2")
include(CTest)
include(Catch)
# additional target to perform clang-format run, requires clang-format
file(GLOB_RECURSE ALL_SOURCE_FILES src/*.cpp src/*.h src/*.hpp test/*.cpp test/*.h test/*.hpp)
#set(CLANG_FORMAT_EXCLUDE "")
#foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
# string(FIND ${SOURCE_FILE} ${CLANG_FORMAT_EXCLUDE} CLANG_FORMAT_EXCLUDE_FOUND)
# if (NOT ${CLANG_FORMAT_EXCLUDE_FOUND} EQUAL -1)
# list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
# endif ()
#endforeach ()
add_custom_target(
clangformat
COMMAND /usr/bin/clang-format
-style=file
-i
${ALL_SOURCE_FILES}
)
add_custom_target(
checkclangformat
DEPENDS ${ALL_SOURCE_FILES}
COMMAND /usr/bin/clang-format
-style=file
--dry-run -Werror --ferror-limit=10
${ALL_SOURCE_FILES}
)
#find_package(RELIC::relic REQUIRED)
#add_subdirectory(extern/relic)
#find_package(RELIC QUIET)
#find_package(RELIC::relic REQUIRED)
#add_library(RELIC::relic STATIC IMPORTED)
#find_package(GMP REQUIRED)
#find_package(Threads REQUIRED)
#find_package(Boost 1.66.0 REQUIRED COMPONENTS thread system)
add_subdirectory(src/)
add_subdirectory(test/)