forked from microsoft/SEAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (63 loc) · 2.65 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.13)
project(SEALBench VERSION 3.7.1 LANGUAGES CXX)
# If not called from root CMakeLists.txt
if(NOT DEFINED SEAL_BUILD_BENCH)
set(SEAL_BUILD_BENCH ON)
# Import Microsoft SEAL
find_package(SEAL 3.7.1 EXACT REQUIRED)
# Must define these variables and include macros
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${OUTLIB_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(SEAL_THIRDPARTY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty)
set(THIRDPARTY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty)
include(FetchContent)
mark_as_advanced(FETCHCONTENT_BASE_DIR)
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_QUIET)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake)
include(SEALMacros)
else()
set(THIRDPARTY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../thirdparty)
endif()
if(NOT DEFINED SEAL_BUILD_DEPS)
# [option] SEAL_BUILD_DEPS (default: ON)
# Download and build missing dependencies, throw error if disabled.
set(SEAL_BUILD_DEPS_OPTION_STR "Automatically download and build unmet dependencies")
option(SEAL_BUILD_DEPS ${SEAL_BUILD_DEPS_OPTION_STR} ON)
endif()
# if SEAL_BUILD_BENCH is ON, use GoogleBenchmark
if(SEAL_BUILD_BENCH)
if(SEAL_BUILD_DEPS)
seal_fetch_thirdparty_content(ExternalBenchmark)
else()
find_package(benchmark REQUIRED)
if(NOT benchmark_FOUND)
message(FATAL_ERROR "GoogleBenchmark: not found")
else()
message(STATUS "GoogleBenchmark: found")
endif()
endif()
add_executable(sealbench)
# If we're targeting WASM, add the appropriate link flags
if(EMSCRIPTEN)
set_target_properties(sealbench PROPERTIES LINK_FLAGS "-flto -O3 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB")
endif()
target_sources(sealbench
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/bench.cpp
${CMAKE_CURRENT_LIST_DIR}/keygen.cpp
${CMAKE_CURRENT_LIST_DIR}/ntt.cpp
${CMAKE_CURRENT_LIST_DIR}/bfv.cpp
${CMAKE_CURRENT_LIST_DIR}/ckks.cpp
)
if(TARGET SEAL::seal)
target_link_libraries(sealbench PRIVATE SEAL::seal benchmark::benchmark)
elseif(TARGET SEAL::seal_shared)
target_link_libraries(sealbench PRIVATE SEAL::seal_shared benchmark::benchmark)
else()
message(FATAL_ERROR "Cannot find target SEAL::seal or SEAL::seal_shared")
endif()
endif()