forked from microsoft/SEAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (65 loc) · 2.72 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.13)
project(SEALTest VERSION 3.7.2 LANGUAGES CXX C)
# If not called from root CMakeLists.txt
if(NOT DEFINED SEAL_BUILD_TESTS)
set(SEAL_BUILD_TESTS ON)
# Import Microsoft SEAL
find_package(SEAL 3.7.2 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_TESTS is ON, use GoogleTest
if(SEAL_BUILD_TESTS)
if(SEAL_BUILD_DEPS)
seal_fetch_thirdparty_content(ExternalGTest)
add_library(GTest::gtest ALIAS gtest)
else()
find_package(GTest 1.10.0 CONFIG)
if(NOT GTest_FOUND)
message(FATAL_ERROR "GoogleTest: not found")
else()
message(STATUS "GoogleTest: found")
endif()
endif()
add_executable(sealtest "")
add_subdirectory(seal)
if(TARGET SEAL::seal)
target_link_libraries(sealtest PRIVATE SEAL::seal GTest::gtest)
elseif(TARGET SEAL::seal_shared)
target_link_libraries(sealtest PRIVATE SEAL::seal_shared GTest::gtest)
else()
message(FATAL_ERROR "Cannot find target SEAL::seal or SEAL::seal_shared")
endif()
# In Debug mode, enable AddressSanitizer (and LeakSanitizer) on Unix-like platforms.
if(SEAL_DEBUG AND UNIX)
# On macOS, only AddressSanitizer is enabled.
# On Linux, LeakSanitizer is enabled by default.
target_compile_options(sealtest PUBLIC -fsanitize=address)
target_link_options(sealtest PUBLIC -fsanitize=address)
if(NOT APPLE)
message(STATUS "Sanitizers enabled: address, leak")
else()
message(STATUS "Sanitizers enabled: address")
endif()
endif()
endif()