forked from PaddlePaddle/PaddleFL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (108 loc) · 4.02 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
cmake_minimum_required(VERSION 3.15)
project(PaddleEncrypted)
add_compile_options(-msse4.2 -fPIC -DPADDLE_WITH_MKLDNN -O2 -Wno-ignored-attributes)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 14)
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIX dll)
elseif (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIX dylib)
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
elseif (LINUX)
set(CMAKE_FIND_LIBRARY_SUFFIX so)
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
endif()
if (NOT PYTHON_EXECUTABLE)
set(PYTHON_EXECUTABLE python)
endif()
find_program(PYTHON ${PYTHON_EXECUTABLE})
if (NOT PYTHON)
message(FATAL_ERROR "${PYTHON_EXECUTABLE} not found")
endif()
option(WITH_TESTING "Compile with unit testing" ON)
option(WITH_PSI "Compile with psi lib" ON)
option(WITH_GRPC "Compile with grpc lib" ON)
if (WITH_GRPC)
add_definitions(-DWITH_GRPC)
endif()
option(USE_AES_NI "Compile with AES NI" ON)
option(USE_OPENMP "Compile with OpenMP" ON)
option(USE_ABY3_TRUNC1 "Compile with ABY3 truncate 1 algorithm" OFF)
option(BUILD_PADDLE_FROM_SOURCE "build paddle from source" OFF)
########################### the project build part ###############################
include(third_party)
include(generic)
include_directories(.)
if (USE_AES_NI)
add_compile_definitions(USE_AES_NI)
add_compile_options(-maes)
endif (USE_AES_NI)
if (USE_OPENMP)
add_compile_options(-fopenmp)
find_package(OpenMP REQUIRED)
endif(USE_OPENMP)
if (USE_ABY3_TRUNC1)
add_compile_definitions(USE_ABY3_TRUNC1)
endif(USE_ABY3_TRUNC1)
add_subdirectory(core/common)
add_subdirectory(core/privc)
add_subdirectory(core/privc3)
add_subdirectory(core/paddlefl_mpc/mpc_protocol)
add_subdirectory(core/paddlefl_mpc/operators)
add_subdirectory(core/paddlefl_mpc/data_utils)
if (WITH_TESTING)
add_subdirectory(core/testing)
endif()
if (WITH_PSI)
add_subdirectory(core/psi)
endif()
add_library(fluid_framework ALIAS paddle_framework)
if (WITH_GRPC)
set(PROTO_SRCS "./core/paddlefl_mpc/mpc_protocol/network/mesh_network_grpc.cc")
set(GRPC_DEPS grpc++_unsecure grpc_unsecure gpr zlib protobuf)
grpc_library(transport_o SRCS ${PROTO_SRCS} PROTO ./core/paddlefl_mpc/mpc_protocol/network/protos/transport.proto DEPS ${GRPC_DEPS})
endif()
# generate dynamic .so lib
add_library(paddle_enc SHARED
$<TARGET_OBJECTS:common_o>
$<TARGET_OBJECTS:mpc_tensor_o>
$<TARGET_OBJECTS:mpc_protocol_o>
$<TARGET_OBJECTS:mpc_ops_o>
$<TARGET_OBJECTS:transport_o>
$<TARGET_OBJECTS:privc_o>)
target_link_libraries(paddle_enc "-Wl,--whole-archive ${ZLIB_LIBRARIES} -Wl,--no-whole-archive" zlib)
target_link_libraries(paddle_enc gmp)
target_link_libraries(paddle_enc gmpxx)
target_link_libraries(paddle_enc seal)
target_link_libraries(paddle_enc gloo)
if (WITH_GRPC)
target_link_libraries(paddle_enc grpc++)
target_link_libraries(paddle_enc grpc++_unsecure)
target_link_libraries(paddle_enc grpc_unsecure)
target_link_libraries(paddle_enc gpr)
target_link_libraries(paddle_enc transport_o)
endif()
target_link_libraries(paddle_enc hiredis)
target_link_libraries(paddle_enc crypto)
target_link_libraries(paddle_enc fluid_framework)
set(CMAKE_SKIP_INSTALL_RPATH TRUE)
set(PADDLE_ENCRYPTED_LIB_PATH "${CMAKE_SOURCE_DIR}/python/paddle_fl/mpc/libs")
if (WITH_GRPC)
install(DIRECTORY "${THIRD_PARTY_PATH}/install/grpc/lib/"
DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH}/third_party)
endif()
install(DIRECTORY "${THIRD_PARTY_PATH}/install/gloo/lib/"
DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH}/third_party)
install(DIRECTORY "${THIRD_PARTY_PATH}/install/hiredis/lib/"
DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH}/third_party)
install(DIRECTORY "${THIRD_PARTY_PATH}/install/openssl/lib/"
DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH}/third_party)
install(TARGETS paddle_enc mpc_data_utils
LIBRARY DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH}
LIBRARY DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH})
if (WITH_PSI)
install(TARGETS psi LIBRARY DESTINATION ${PADDLE_ENCRYPTED_LIB_PATH})
endif()