-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
94 lines (76 loc) · 3.24 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
cmake_minimum_required (VERSION 3.10)
project (agmpc_matcher)
set(NAME "agmpc_matcher")
cmake_policy(SET CMP0042 NEW)
set (CMAKE_CXX_STANDARD 17)
if( NODE_RUNTIMEVERSION VERSION_GREATER_EQUAL "17.0.0")
add_compile_definitions(OPENSSL_API_COMPAT=0x10100001L)
add_compile_definitions(OPENSSL_CONFIGURED_API=0x30000000L)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
#add_compile_options(-fsanitize=undefined)
#add_link_options(-fsanitize=undefined)
include(cmake/common.cmake)
include(cmake/source_of_randomness.cmake)
include(cmake/threading.cmake)
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(emp-agmpc REQUIRED)
find_package(GMP REQUIRED)
set(EMP-TOOL_LIBRARIES
${EMP-TOOL_LIBRARY}
${OPENSSL_LIBRARIES}
${Boost_LIBRARIES}
${GMP_LIBRARIES})
set(EMP_INCLUDE_DIRS
${EMP-TOOL_INCLUDE_DIR}
${EMP-OT_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${GMP_INCLUDE_DIR})
file(GLOB AGMPC_SINGLEATT_SOURCES
"src/mpc_addon/agmpc_matcher.cc"
"src/mpc_addon/agmpc_matcher.h")
add_definitions(-DCIRCUIT_DIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
# Include Node-API wrappers
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REGEX REPLACE "[\r\n\"]" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
message(STATUS "NODE_ADDON_API_DIR is ${NODE_ADDON_API_DIR}")
#target_include_directories(agmpc_matcher PRIVATE ${NODE_ADDON_API_DIR})
add_definitions(-DNAPI_VERSION=3)
#include_directories(${CMAKE_JS_INC} "${NODE_ADDON_API_DIR}")
# AGMPC matcher lib
add_library(agmpc_matcher SHARED ${AGMPC_SINGLEATT_SOURCES})
target_link_libraries(agmpc_matcher ${EMP-TOOL_LIBRARIES})
target_include_directories(agmpc_matcher PUBLIC ${EMP_INCLUDE_DIRS} "src/mpc_addon")
# AGMPC lib napi binding
add_library(agmpc_matcher_napi SHARED
"src/mpc_addon/agmpc_matcher_napi.cc"
${CMAKE_JS_SRC})
target_include_directories(agmpc_matcher_napi PUBLIC ${CMAKE_JS_INC} ${NODE_ADDON_API_DIR} "src/mpc_addon")
set_target_properties(agmpc_matcher_napi PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries(agmpc_matcher_napi ${CMAKE_JS_LIB} agmpc_matcher)
# AGMPC matcher executable
add_executable(agmpc_matcher_main "src/mpc_addon/agmpc_matcher_main.cc")
target_link_libraries(agmpc_matcher_main agmpc_matcher)
target_include_directories(agmpc_matcher_main PUBLIC "src/mpc_addon")
# AGMPC matcher circuit generation
add_executable(agmpc_matcher_circuit_generator "src/mpc_addon/agmpc_matcher_circuit_generator.cc")
target_link_libraries(agmpc_matcher_circuit_generator ${EMP-TOOL_LIBRARIES})
target_include_directories(agmpc_matcher_circuit_generator PUBLIC ${EMP_INCLUDE_DIRS} "src/mpc_addon")
add_custom_target(agmpc_generate_circuits
./agmpc_matcher_circuit_generator 10
DEPENDS agmpc_matcher_circuit_generator
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/build/bin"
)
add_dependencies(agmpc_matcher agmpc_generate_circuits)
add_dependencies(agmpc_matcher_main agmpc_generate_circuits)
add_dependencies(agmpc_matcher_napi agmpc_generate_circuits)