Make SEAL a CMake project and enable auto-download of dependencies

This commit is contained in:
Wei Dai 2020-01-31 11:08:36 -08:00 коммит произвёл Kim Laine
Родитель 0389ed6a51
Коммит 4bc0872204
43 изменённых файлов: 658 добавлений и 530 удалений

14
.gitignore поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
# Other stuff
native/src/cmake/SEALConfig.cmake
native/src/cmake/SEALConfigVersion.cmake
native/src/cmake/SEALTargets.cmake
cmake/SEALConfig.cmake
cmake/SEALConfigVersion.cmake
cmake/SEALTargets.cmake
native/src/seal/util/config.h
**/CMakeCache.txt
**/CMakeFiles
@ -21,8 +21,12 @@ native/src/seal/util/config.h
**/compile_commands.json
**/.DS_Store
**/GSL
native/src/thirdparty/zlib/*
!native/src/thirdparty/zlib/CMakeLists.txt
thirdparty/zlib/*
!thirdparty/zlib/CMakeLists.txt
thirdparty/msgsl/*
!thirdparty/msgsl/CMakeLists.txt
thirdparty/googletest/*
!thirdparty/googletest/CMakeLists.txt
dotnet/nuget/nuget.exe
dotnet/nuget/SEALNet.nuspec
dotnet/nuget/SEALNet.targets

3
.gitmodules поставляемый
Просмотреть файл

@ -1,3 +0,0 @@
[submodule "native/tests/thirdparty/googletest"]
path = native/tests/thirdparty/googletest
url = https://github.com/google/googletest

Просмотреть файл

@ -3,8 +3,17 @@
cmake_minimum_required(VERSION 3.12)
###################################################
# Project SEAL includes the following components: #
# 1. SEAL C++ library #
# 2. SEAL C export library #
# 3. SEAL C++ examples #
# 4. SEAL C++ tests #
###################################################
project(SEAL VERSION 3.5.0 LANGUAGES CXX C)
# Check operating system: for Windows, use Visual Studio solution/project files.
if(MSVC)
if(ALLOW_COMMAND_LINE_BUILD)
message(STATUS "Configuring for Visual Studio")
@ -13,78 +22,29 @@ if(MSVC)
endif()
endif()
########################
# Global configuration #
########################
# [Option] CMAKE_BUILD_TYPE
# Build in Release mode by default; otherwise use selected option
set(SEAL_DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${SEAL_DEFAULT_BUILD_TYPE} CACHE
STRING "Build type" FORCE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Release" "Debug" "MinSizeRel" "RelWithDebInfo")
endif()
message(STATUS "Build type (CMAKE_BUILD_TYPE): ${CMAKE_BUILD_TYPE}")
# In Debug mode enable also SEAL_DEBUG by default
# [Flag] SEAL_DEBUG
# In Debug mode, enable SEAL_DEBUG
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SEAL_DEBUG_DEFAULT ON)
set(SEAL_DEBUG ON)
else()
set(SEAL_DEBUG_DEFAULT OFF)
set(SEAL_DEBUG OFF)
endif()
# Required files and directories
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SEAL_SOURCE_DIR}/../lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SEAL_SOURCE_DIR}/../lib)
set(CMAKE_LIBRARY_RUNTIME_DIRECTORY ${SEAL_SOURCE_DIR}/../bin)
set(SEAL_TARGETS_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALTargets.cmake)
set(SEAL_CONFIG_IN_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALConfig.cmake.in)
set(SEAL_CONFIG_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALConfig.cmake)
set(SEAL_CONFIG_VERSION_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALConfigVersion.cmake)
set(SEAL_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/SEAL-${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
set(SEAL_INCLUDES_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/SEAL-${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
set(MSGSL_FIND_MODULE_PATH ${SEAL_SOURCE_DIR}/cmake/FindMSGSL.cmake)
# For extra modules we might have
list(APPEND CMAKE_MODULE_PATH ${SEAL_SOURCE_DIR}/cmake)
include(CMakePushCheckState)
include(CMakeDependentOption)
include(CheckIncludeFiles)
include(CheckCXXSourceRuns)
include(CheckTypeSize)
# For easier adding of CXX compiler flags
include(CheckCXXCompilerFlag)
function(enable_cxx_compiler_flag_if_supported flag)
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
message(STATUS "Adding CXX compiler flag: ${flag} ...")
check_cxx_compiler_flag("${flag}" flag_supported)
if(flag_supported)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
unset(flag_supported CACHE)
endif()
endfunction()
# enable_cxx_compiler_flag_if_supported("-Wall")
# enable_cxx_compiler_flag_if_supported("-Wextra")
# enable_cxx_compiler_flag_if_supported("-Wconversion")
# enable_cxx_compiler_flag_if_supported("-Wshadow")
# enable_cxx_compiler_flag_if_supported("-pedantic")
# Are we using SEAL_DEBUG?
set(SEAL_DEBUG ${SEAL_DEBUG_DEFAULT})
message(STATUS "Microsoft SEAL debug mode: ${SEAL_DEBUG}")
# Should we build also the shared library?
set(BUILD_SHARED_LIBS_STR "Build shared library")
option(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_STR} OFF)
if(MSVC AND BUILD_SHARED_LIBS)
message(WARNING "This build system only supports a static build; disabling `BUILD_SHARED_LIBS`")
set(BUILD_SHARED_LIBS OFF CACHE)
endif()
# [Option] SEAL_USE_CXX17
# Should we use C++14 or C++17?
set(SEAL_USE_CXX17_OPTION_STR "Use C++17")
option(SEAL_USE_CXX17 ${SEAL_USE_CXX17_OPTION_STR} ON)
@ -105,6 +65,202 @@ if(SEAL_USE_CXX17)
set(SEAL_LANG_FLAG "-std=c++17")
endif()
# [Option] CXX compiler flags
# For easier adding of CXX compiler flags
include(CheckCXXCompilerFlag)
function(enable_cxx_compiler_flag_if_supported flag)
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
message(STATUS "Adding CXX compiler flag: ${flag} ...")
check_cxx_compiler_flag("${flag}" flag_supported)
if(flag_supported)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
unset(flag_supported CACHE)
endif()
endfunction()
# In Debug mode, enable extra compiler flags.
if(SEAL_DEBUG)
enable_cxx_compiler_flag_if_supported("-Wall")
enable_cxx_compiler_flag_if_supported("-Wextra")
enable_cxx_compiler_flag_if_supported("-Wconversion")
enable_cxx_compiler_flag_if_supported("-Wshadow")
enable_cxx_compiler_flag_if_supported("-pedantic")
endif()
# Required files and directories
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SEAL_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SEAL_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_RUNTIME_DIRECTORY ${SEAL_SOURCE_DIR}/bin)
set(SEAL_TARGETS_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALTargets.cmake)
set(SEAL_CONFIG_IN_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALConfig.cmake.in)
set(SEAL_CONFIG_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALConfig.cmake)
set(SEAL_CONFIG_VERSION_FILENAME ${SEAL_SOURCE_DIR}/cmake/SEALConfigVersion.cmake)
set(SEAL_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/SEAL-${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
set(SEAL_INCLUDES_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/SEAL-${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
set(SEAL_INCLUDES_BUILD_DIR ${SEAL_SOURCE_DIR}/native/src)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SEAL_SOURCE_DIR}/bin)
# For extra modules we might have
list(APPEND CMAKE_MODULE_PATH ${SEAL_SOURCE_DIR}/cmake)
include(CMakePushCheckState)
include(CMakeDependentOption)
include(CheckIncludeFiles)
include(CheckCXXSourceRuns)
include(CheckTypeSize)
##################################
# Macros for configuring targets #
##################################
# Set the C++ language version
macro(set_language target)
if(SEAL_USE_CXX17)
target_compile_features(${target} PUBLIC cxx_std_17)
else()
target_compile_features(${target} PUBLIC cxx_std_14)
endif()
endmacro()
# Set the VERSION property
macro(set_version target)
set_target_properties(${target} PROPERTIES VERSION ${SEAL_VERSION})
endmacro()
# Set the library filename to reflect version
macro(set_version_filename target)
set_target_properties(${target} PROPERTIES
OUTPUT_NAME ${target}-${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
endmacro()
# Set the SOVERSION property
macro(set_soversion target)
set_target_properties(${target} PROPERTIES
SOVERSION ${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
endmacro()
# Set include directories for build and install interfaces
macro(set_include_directories target)
target_include_directories(${target} PUBLIC
$<BUILD_INTERFACE:${SEAL_INCLUDES_BUILD_DIR}>
$<INSTALL_INTERFACE:${SEAL_INCLUDES_INSTALL_DIR}>)
endmacro()
# Link a thread library
macro(link_threads target)
# Require thread library
if(NOT TARGET Threads::Threads)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
endif()
# Link Threads
target_link_libraries(${target} PUBLIC Threads::Threads)
endmacro()
# Include target to given export
macro(install_target target export)
install(TARGETS ${target} EXPORT ${export}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endmacro()
#########################
# External dependencies #
#########################
# Use Microsoft GSL
set(SEAL_USE_MSGSL_OPTION_STR "Use Microsoft GSL")
option(SEAL_USE_MSGSL ${SEAL_USE_MSGSL_OPTION_STR} ON)
if(SEAL_USE_MSGSL AND NOT MSVC)
add_subdirectory(thirdparty/msgsl)
ExternalProject_Get_Property(msgsl_external SOURCE_DIR)
add_library(msgsl IMPORTED INTERFACE)
# We need to create the include directory so it exists at the time
# of configuration. Otherwise set_target_properties below will fail.
set(MSGSL_INCLUDE_DIR ${SOURCE_DIR}/include)
file(MAKE_DIRECTORY ${MSGSL_INCLUDE_DIR})
set_target_properties(msgsl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${MSGSL_INCLUDE_DIR})
add_dependencies(msgsl msgsl_external)
endif()
# Use ZLIB
set(SEAL_USE_ZLIB_OPTION_STR "Use ZLIB for compressed serialization")
option(SEAL_USE_ZLIB ${SEAL_USE_ZLIB_OPTION_STR} ON)
if(SEAL_USE_ZLIB AND NOT MSVC)
add_subdirectory(thirdparty/zlib)
ExternalProject_Get_Property(zlib_external SOURCE_DIR BINARY_DIR)
add_library(zlibstatic STATIC IMPORTED)
set(ZLIB_FILENAME "libz.a")
set(ZLIB_LIBRARY_PATH ${BINARY_DIR}/${ZLIB_FILENAME})
set_target_properties(zlibstatic PROPERTIES
IMPORTED_LOCATION ${ZLIB_LIBRARY_PATH})
set_target_properties(zlibstatic PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR})
add_dependencies(zlibstatic zlib_external)
endif()
# Use Google Test
if(SEAL_BUILD_TESTS AND NOT MSVC)
# This follows the example in
# https://github.com/google/googletest/blob/release-1.10.0/googletest/README.md.
# Download
message(STATUS "Setting up Google Test ...")
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
OUTPUT_QUIET
RESULT_VARIABLE result
WORKING_DIRECTORY thirdparty/googletest)
if(result)
message(WARNING "Failed to download Google Test (${result}); disabling `SEAL_BUILD_TESTS`")
endif()
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
mark_as_advanced(BUILD_GMOCK)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
mark_as_advanced(INSTALL_GTEST)
# Build
execute_process(COMMAND ${CMAKE_COMMAND} --build .
OUTPUT_QUIET
RESULT_VARIABLE result
WORKING_DIRECTORY thirdparty/googletest)
if(result)
message(WARNING "Failed to build Google Test (${result}); disabling `SEAL_BUILD_TESTS`")
endif()
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Set up the targets
add_subdirectory(
thirdparty/googletest/googletest-src
thirdparty/googletest/googletest-build
EXCLUDE_FROM_ALL)
endif()
####################
# SEAL C++ library #
####################
# Should we build also the shared library?
set(BUILD_SHARED_LIBS_STR "Build shared library")
option(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_STR} OFF)
if(MSVC AND BUILD_SHARED_LIBS)
message(WARNING "This build system only supports a static build; disabling `BUILD_SHARED_LIBS`")
set(BUILD_SHARED_LIBS OFF CACHE BOOL ${BUILD_SHARED_LIBS_STR} FORCE)
endif()
# Always build position-independent-code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -117,14 +273,6 @@ mark_as_advanced(FORCE SEAL_THROW_ON_TRANSPARENT_CIPHERTEXT)
set(SEAL_USE_INTRIN_OPTION_STR "Use intrinsics")
option(SEAL_USE_INTRIN ${SEAL_USE_INTRIN_OPTION_STR} ON)
# Use Microsoft GSL if available
set(SEAL_USE_MSGSL_OPTION_STR "Use Microsoft GSL")
option(SEAL_USE_MSGSL ${SEAL_USE_MSGSL_OPTION_STR} ON)
# Use zlib if available
set(SEAL_USE_ZLIB_OPTION_STR "Use zlib for compressed serialization")
option(SEAL_USE_ZLIB ${SEAL_USE_ZLIB_OPTION_STR} ON)
# Check for intrin.h or x64intrin.h
if(SEAL_USE_INTRIN)
if(MSVC)
@ -260,206 +408,98 @@ if(SEAL_USE_INTRIN)
cmake_pop_check_state()
endif()
# Helper macro for clearing MSGSL cache
macro(clear_msgsl_cache)
unset(MSGSL_INCLUDE_DIR CACHE)
endmacro()
# Try to find MSGSL if requested; first clear the cache if SEAL_USE_MSGSL
# is not set, or if SEAL_USE_MSGSL and MSGSL_ROOT are set (force search).
if(NOT SEAL_USE_MSGSL OR MSGSL_ROOT)
clear_msgsl_cache()
endif()
if(SEAL_USE_MSGSL)
find_package(MSGSL MODULE)
if(NOT MSGSL_FOUND)
set(SEAL_USE_MSGSL OFF CACHE BOOL ${SEAL_USE_MSGSL_OPTION_STR} FORCE)
clear_msgsl_cache()
endif()
endif()
# Specific options depending on SEAL_USE_MSGSL
set(SEAL_USE_MSGSL_SPAN_OPTION_STR "Use gsl::span")
cmake_dependent_option(SEAL_USE_MSGSL_SPAN ${SEAL_USE_MSGSL_SPAN_OPTION_STR} ON "SEAL_USE_MSGSL" OFF)
if(SEAL_USE_MSGSL_SPAN)
# Detect gsl::span
if(NOT HAVE_MSGSL_SPAN)
set(SEAL_USE_MSGSL_SPAN OFF CACHE BOOL ${SEAL_USE_MSGSL_SPAN_OPTION_STR} FORCE)
endif()
endif()
# Helper macro for clearing zlib cache
macro(clear_zlib_cache)
unset(ZLIB_INCLUDE_DIR CACHE)
unset(ZLIB_LIBRARY CACHE)
unset(ZLIB_LIBRARY_DEBUG CACHE)
unset(ZLIB_LIBRARY_RELEASE CACHE)
endmacro()
# Try to find zlib if requested; first clear the cache if SEAL_USE_ZLIB
# is not set, or if SEAL_USE_ZLIB and ZLIB_ROOT are set (force search).
if(NOT SEAL_USE_ZLIB OR ZLIB_ROOT)
clear_zlib_cache()
endif()
if(SEAL_USE_ZLIB)
find_package(ZLIB 1.2.11 EXACT)
if(NOT ZLIB_FOUND)
set(SEAL_USE_ZLIB OFF CACHE BOOL ${SEAL_USE_ZLIB_OPTION_STR} FORCE)
clear_zlib_cache()
endif()
endif()
# Set the sealc dynamic library file names to be included in creating
# the NuGet package. When building a multi-platform package, all three paths
# should be included.
if(SEAL_MULTIPLATFORM_NUGET_BUILD)
set(SEAL_WINDOWS_SEAL_C_PATH ../../native/lib/x64/$Configuration$/sealc.dll)
set(SEAL_LINUX_SEAL_C_PATH ../../native/lib/libsealc.so.${SEAL_VERSION})
set(SEAL_MACOS_SEAL_C_PATH ../../native/lib/libsealc.${SEAL_VERSION}.dylib)
else()
if(MSVC)
set(SEAL_WINDOWS_SEAL_C_PATH ../../native/lib/x64/$Configuration$/sealc.dll)
elseif(APPLE)
set(SEAL_MACOS_SEAL_C_PATH ../../native/lib/libsealc.${SEAL_VERSION}.dylib)
elseif(UNIX)
set(SEAL_LINUX_SEAL_C_PATH ../../native/lib/libsealc.so.${SEAL_VERSION})
endif()
endif()
# Create SEALNet.nuspec from SEALNet.nuspec.in
configure_file(
${SEAL_SOURCE_DIR}/../../dotnet/nuget/SEALNet.nuspec.in
${SEAL_SOURCE_DIR}/../../dotnet/nuget/SEALNet.nuspec
@ONLY)
# Create SEALNet.targets from SEALNet.targets.in
configure_file(
${SEAL_SOURCE_DIR}/../../dotnet/nuget/SEALNet.targets.in
${SEAL_SOURCE_DIR}/../../dotnet/nuget/SEALNet.targets
@ONLY)
# Set the C++ language version
macro(set_language target)
if(SEAL_USE_CXX17)
target_compile_features(${target} PUBLIC cxx_std_17)
else()
target_compile_features(${target} PUBLIC cxx_std_14)
endif()
endmacro()
# Set the VERSION property
macro(set_version target)
set_target_properties(${target} PROPERTIES VERSION ${SEAL_VERSION})
endmacro()
# Set the library filename to reflect version
macro(set_version_filename target)
set_target_properties(seal PROPERTIES
OUTPUT_NAME seal-${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
endmacro()
# Set the SOVERSION property
macro(set_soversion target)
set_target_properties(${target} PROPERTIES
SOVERSION ${SEAL_VERSION_MAJOR}.${SEAL_VERSION_MINOR})
endmacro()
# Set include directories for build and install interfaces
macro(set_include_directories target)
target_include_directories(${target} PUBLIC
$<BUILD_INTERFACE:${SEAL_SOURCE_DIR}>
$<INSTALL_INTERFACE:${SEAL_INCLUDES_INSTALL_DIR}>)
endmacro()
# Link all dependencies
macro(link_dependencies target)
# Require thread library
if(NOT TARGET Threads::Threads)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
endif()
# Link Threads
target_link_libraries(${target} PUBLIC Threads::Threads)
if(SEAL_USE_MSGSL)
# Link MSGSL
target_link_libraries(${target} PUBLIC MSGSL::MSGSL)
endif()
if(SEAL_USE_ZLIB)
# Link ZLIB
target_link_libraries(${target} PUBLIC ZLIB::ZLIB)
endif()
endmacro()
# Create an object library to compile sources only once
add_library(seal_obj OBJECT)
# Add source files to library and header files to install
add_subdirectory(seal)
add_subdirectory(native/src/seal)
# Set C++ language version and include directories for the object library
set_language(seal_obj)
set_include_directories(seal_obj)
if(SEAL_USE_MSGSL AND NOT MSVC)
# Make sure Microsoft GSL is downloaded
target_link_libraries(seal_obj PUBLIC msgsl)
endif()
if(SEAL_USE_ZLIB AND NOT MSVC)
# Make sure ZLIB is downloaded
target_link_libraries(seal_obj PRIVATE zlibstatic)
endif()
# Always build the static library
add_library(seal STATIC $<TARGET_OBJECTS:seal_obj>)
set_version(seal)
set_version_filename(seal)
set_language(seal)
set_include_directories(seal)
link_dependencies(seal)
link_threads(seal)
install_target(seal SEALTargets)
if(SEAL_USE_MSGSL AND NOT MSVC)
# In UNIX-like platforms copy Microsoft GSL include files into native/src
add_custom_command(TARGET seal POST_BUILD
COMMAND cp -r ${MSGSL_INCLUDE_DIR}/gsl ${SEAL_INCLUDES_BUILD_DIR})
endif()
if(SEAL_USE_ZLIB AND NOT MSVC)
# In UNIX-like platforms combine manually seal and zlibstatic
# into a single archive; not pretty, but works
add_custom_command(TARGET seal POST_BUILD
COMMAND ar x $<TARGET_FILE:seal>
COMMAND ar x ${ZLIB_LIBRARY_PATH}
COMMAND ar rcs $<TARGET_FILE:seal> *.o
COMMAND rm -f *.o
WORKING_DIRECTORY $<TARGET_FILE_DIR:seal>)
endif()
# Conditionally build the shared library
if(BUILD_SHARED_LIBS)
add_library(seal_shared SHARED $<TARGET_OBJECTS:seal_obj>)
set_target_properties(seal_shared PROPERTIES OUTPUT_NAME seal)
set_version(seal_shared)
set_soversion(seal_shared)
set_language(seal_shared)
set_include_directories(seal_shared)
link_dependencies(seal_shared)
link_threads(seal_shared)
if(SEAL_USE_ZLIB AND NOT MSVC)
# In the shared build we link zlibstatic into the shared library
target_link_libraries(seal_shared PRIVATE zlibstatic)
endif()
install_target(seal_shared SEALTargets)
endif()
# For SEAL_C check that size_t is 8 bytes
#########################
# SEAL C export library #
#########################
# Check that size_t is 8 bytes
include(CheckTypeSize)
check_type_size("size_t" SIZET LANGUAGE C)
set(SEAL_BUILD_SEAL_C_OPTION_STR "Build C export library for Microsoft SEAL")
cmake_dependent_option(SEAL_BUILD_SEAL_C ${SEAL_BUILD_SEAL_C_OPTION_STR}
OFF "${SIZET} EQUAL 8" OFF)
cmake_dependent_option(SEAL_BUILD_SEAL_C ${SEAL_BUILD_SEAL_C_OPTION_STR} OFF "${SIZET} EQUAL 8" OFF)
# Create shared SEAL_C library but add no source files yet
if(SEAL_BUILD_SEAL_C)
add_library(sealc SHARED)
# Add source files to library and header files to install
add_subdirectory(seal/c)
add_subdirectory(native/src/seal/c)
set_version(sealc)
set_soversion(sealc)
set_language(sealc)
set_include_directories(sealc)
link_dependencies(sealc)
target_link_libraries(sealc PUBLIC seal)
install_target(sealc SEALTargets)
endif()
macro(install_target_if_exists target export)
if(TARGET ${target})
install(TARGETS ${target} EXPORT ${export}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endmacro()
# Associate seal and seal_shared to export SEALTargets
install_target_if_exists(seal SEALTargets)
install_target_if_exists(seal_shared SEALTargets)
install_target_if_exists(sealc SEALTargets)
#################################
# Installation and CMake config #
#################################
# Create the CMake config file
include(CMakePackageConfigHelpers)
@ -493,3 +533,71 @@ export(
EXPORT SEALTargets
NAMESPACE SEAL::
FILE ${SEAL_TARGETS_FILENAME})
#####################
# SEAL C++ examples #
#####################
set(SEAL_BUILD_EXAMPLES_OPTION_STR "Build C++ examples for Microsoft SEAL")
option(SEAL_BUILD_EXAMPLES ${SEAL_BUILD_EXAMPLES_OPTION_STR} OFF)
if(SEAL_BUILD_EXAMPLES)
add_executable(sealexamples)
add_subdirectory(native/examples)
target_link_libraries(sealexamples PRIVATE seal)
endif()
##################
# SEAL C++ tests #
##################
set(SEAL_BUILD_TESTS_OPTION_STR "Build C++ tests for Microsoft SEAL")
option(SEAL_BUILD_TESTS ${SEAL_BUILD_TESTS_OPTION_STR} OFF)
if(SEAL_BUILD_TESTS)
add_executable(sealtests)
add_subdirectory(native/tests)
target_link_libraries(sealtests PRIVATE seal gtest)
endif()
#######################################
# Configure SEALNet and NuGet package #
#######################################
# Set the sealc dynamic library file names to be included in creating
# the NuGet package. When building a multi-platform package, all three
# paths should be included.
set(SEAL_WINDOWS_SEAL_C_PATH_ ${SEAL_SOURCE_DIR}/lib/x64/$Configuration$/sealc.dll)
set(SEAL_LINUX_SEAL_C_PATH_ ${SEAL_SOURCE_DIR}/lib/libsealc.so.${SEAL_VERSION})
set(SEAL_MACOS_SEAL_C_PATH_ ${SEAL_SOURCE_DIR}/lib/libsealc.${SEAL_VERSION}.dylib)
unset(SEAL_WINDOWS_SEAL_C_PATH)
unset(SEAL_LINUX_SEAL_C_PATH)
unset(SEAL_MACOS_SEAL_C_PATH)
if(SEAL_MULTIPLATFORM_NUGET_BUILD)
set(SEAL_WINDOWS_SEAL_C_PATH ${SEAL_WINDOWS_SEAL_C_PATH_})
set(SEAL_LINUX_SEAL_C_PATH ${SEAL_LINUX_SEAL_C_PATH_})
set(SEAL_MACOS_SEAL_C_PATH ${SEAL_MACOS_SEAL_C_PATH_})
else()
if(MSVC)
set(SEAL_WINDOWS_SEAL_C_PATH ${SEAL_WINDOWS_SEAL_C_PATH_})
elseif(UNIX)
set(SEAL_LINUX_SEAL_C_PATH ${SEAL_LINUX_SEAL_C_PATH_})
elseif(APPLE)
set(SEAL_MACOS_SEAL_C_PATH ${SEAL_MACOS_SEAL_C_PATH_})
endif()
endif()
# Create SEALNet.nuspec from SEALNet.nuspec.in
configure_file(
${SEAL_SOURCE_DIR}/dotnet/nuget/SEALNet.nuspec.in
${SEAL_SOURCE_DIR}/dotnet/nuget/SEALNet.nuspec
@ONLY)
# Create SEALNet.targets from SEALNet.targets.in
configure_file(
${SEAL_SOURCE_DIR}/dotnet/nuget/SEALNet.targets.in
${SEAL_SOURCE_DIR}/dotnet/nuget/SEALNet.targets
@ONLY)

Просмотреть файл

@ -20,6 +20,10 @@
- Microsoft SEAL now compiles also in FreeBSD ([PR 113](https://github.com/microsoft/SEAL/pull/113)).
- In serialization, unsupported compression mode now throws `std::invalid_argument` (native) or `ArgumentException` (.NET).
- Examples for serialization have been added.
- ZLIB is now downloaded and compiled by default by CMake, and included into a static/dynamic target object (can be disabled).
- Microsoft GSL is now downloaded automatically (can be disabled).
- Google Test is now downloaded and compiled by CMake and is no longer included as a Git submodule.
- Releases are now listed on GitHub.
- Moved `dotnet/native/` to be under `native/src/c/`. The C export library in this directory can be used to build wrappers for other languages also -- not just .NET.
- Changed the CMake file structure. Targets available are now: `SEAL::seal` (static library), `SEAL::seal_shared` (shared library), `SEAL::sealc` (C export library).

Просмотреть файл

@ -1,16 +1,16 @@
# Issues
# Issues
## Technical questions
The best way to get help with technical questions is on
[StackOverflow](https://stackoverflow.com/questions/tagged/seal) using the `[seal]`
The best way to get help with technical questions is on
[StackOverflow](https://stackoverflow.com/questions/tagged/seal) using the `[seal]`
tag. To contact the Microsoft SEAL team directly, please email
[sealcrypto@microsoft.com](mailto:sealcrypto@microsoft.com).
## Bug reports
We appreciate community efforts to find and fix bugs and issues in Microsoft SEAL.
If you believe you have found a bug or want to report some other issue, please
We appreciate community efforts to find and fix bugs and issues in Microsoft SEAL.
If you believe you have found a bug or want to report some other issue, please
do so on [GitHub](https://github.com/Microsoft/SEAL/issues). To help others
determine what the problem may be, we provide a helpful script that collects
relevant system information that you can submit with the bug report (see below).
@ -21,7 +21,7 @@ To collect system information for an improved bug report, please run
```
make -C tools system_info
```
This will result in a file `system_info.tar.gz` to be generated, which you can
This will result in a file `system_info.tar.gz` to be generated, which you can
optionally attach with your bug report.
## Critical security issues

Просмотреть файл

@ -121,8 +121,8 @@ Studio 2017 version 15.3 or newer is required to build Microsoft SEAL.
The Visual Studio solution `SEAL.sln` is configured to build Microsoft SEAL both
for `Win32` and `x64` platforms. Please choose the right platform before building
Microsoft SEAL. The `SEALNetNative` project or the .NET wrapper library `SEALNet`
can only be built for `x64`.
Microsoft SEAL. The `SEAL_C` project and the .NET wrapper library `SEALNet` can only
be built for `x64`.
#### Debug and Release builds
@ -134,7 +134,7 @@ as the performance will be orders of magnitude worse than in `Release` mode.
#### Building Microsoft SEAL
Build the SEAL project `native\src\SEAL.vcxproj` from `SEAL.sln`. This results in
the static library `seal.lib` to be created in `native\lib\$(Platform)\$(Configuration)`.
the static library `seal.lib` to be created in `lib\$(Platform)\$(Configuration)`.
When linking with applications, you need to add `native\src\` (full path) as an
include directory for Microsoft SEAL header files.
@ -142,7 +142,7 @@ include directory for Microsoft SEAL header files.
Build the SEALExamples project `native\examples\SEALExamples.vcxproj` from `SEAL.sln`.
This results in an executable `sealexamples.exe` to be created in
`native\bin\$(Platform)\$(Configuration)`.
`bin\$(Platform)\$(Configuration)`.
#### Building Unit Tests
@ -240,7 +240,7 @@ cd ../..
It is very easy to link your own applications and libraries with Microsoft SEAL if
you use CMake. Simply add the following to your `CMakeLists.txt`:
````
find_package(SEAL 3.4 REQUIRED)
find_package(SEAL 3.5 REQUIRED)
target_link_libraries(<your target> SEAL::seal)
````
If Microsoft SEAL was installed globally, the above `find_package` command will likely
@ -266,14 +266,10 @@ enabled if it is compiled with support for specific third-party libraries.
## Microsoft GSL
Microsoft GSL (Guidelines Support Library) is a header-only library that implements
two convenient (templated) data types: `gsl::span` and `gsl::multi_span`. These
are *view types* that provide safe (bounds-checked) array access to memory. For
example, if Microsoft GSL is available, Microsoft SEAL can allow `BatchEncoder`
`gsl::span`: a *view type* that provide safe (bounds-checked) array access to memory.
For example, if Microsoft GSL is available, Microsoft SEAL can allow `BatchEncoder`
and `CKKSEncoder` to encode from and decode to a `gsl::span` instead of `std::vector`,
which can have significant benefit in performance. Additionally, `BatchEncoder` allows
access to the slot data alternatively through a two-dimensional `gsl::multi_span`,
reflecting the batching slot structure. Also the `Ciphertext` class allows the
ciphertext data to be accessed hierarchically through a `gsl::multi_span`.
which can in some cases have a significant performance benefit.
#### Microsoft GSL in Windows
@ -546,7 +542,7 @@ It is recommeded to read the comments and the code snippets along with command l
from running an example. For easier navigation, command line printout provides the line number
in the associated source file where the associated code snippets start.
**WARNING: It is impossible to use Microsoft SEAL correctly without reading all examples
**WARNING: It is impossible to use Microsoft SEAL correctly without reading all examples
or by simply re-using the code from examples. Any developer attempting to do so
will inevitably produce code that is *vulnerable*, *malfunctioning*, or *extremely slow*.**

Просмотреть файл

@ -42,6 +42,46 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{33C15AAC
dotnet\nuget\SEALNet.targets.in = dotnet\nuget\SEALNet.targets.in
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C73A600E-7F50-467C-9228-58AC2C1A7DDA}"
ProjectSection(SolutionItems) = preProject
.clang-format = .clang-format
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
Changes.md = Changes.md
CMakeLists.txt = CMakeLists.txt
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
CONTRIBUTING.md = CONTRIBUTING.md
ISSUES.md = ISSUES.md
LICENSE = LICENSE
NOTICE = NOTICE
README.md = README.md
SECURITY.md = SECURITY.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{0518DDC0-82BC-4E7C-A24D-98B8EA9C47B3}"
ProjectSection(SolutionItems) = preProject
templates\nix-build.yml = templates\nix-build.yml
templates\pack.yml = templates\pack.yml
templates\windows-build.yml = templates\windows-build.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "thirdparty", "thirdparty", "{6B00D0DE-8A17-44B8-BF47-F372E9189434}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "zlib", "zlib", "{5E524D23-AD60-45AF-B279-0322941E9F31}"
ProjectSection(SolutionItems) = preProject
thirdparty\zlib\CMakeLists.txt = thirdparty\zlib\CMakeLists.txt
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msgsl", "msgsl", "{B4EF7358-C76B-4142-9746-B082114B1DDD}"
ProjectSection(SolutionItems) = preProject
thirdparty\msgsl\CMakeLists.txt = thirdparty\msgsl\CMakeLists.txt
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "googletest", "googletest", "{0DD76E94-59E1-49D4-9ED7-8C696B89F26E}"
ProjectSection(SolutionItems) = preProject
thirdparty\googletest\CMakeLists.txt = thirdparty\googletest\CMakeLists.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -114,11 +154,16 @@ Global
{7EA96C25-FC0D-485A-BB71-32B6DA55652A} = {A5BADDF0-1F03-48FE-AAC0-3355614C9A8D}
{0345DC4D-EFE3-460E-AB7E-AA6E05BB8DFF} = {A5BADDF0-1F03-48FE-AAC0-3355614C9A8D}
{2B57D847-26DC-45FF-B9AF-EE33910B5093} = {A5BADDF0-1F03-48FE-AAC0-3355614C9A8D}
{70BBB2AA-FA77-40C1-890F-7AA7DBB3AD3D} = {0786F255-C3A7-4912-A669-12273E7AE013}
{70BBB2AA-FA77-40C1-890F-7AA7DBB3AD3D} = {A5BADDF0-1F03-48FE-AAC0-3355614C9A8D}
{D7ED94EC-3FAB-4B87-AB5F-0308EA92520E} = {0786F255-C3A7-4912-A669-12273E7AE013}
{D0FCCA29-F0F8-49A3-9615-24FF899F1909} = {0786F255-C3A7-4912-A669-12273E7AE013}
{18DA9F90-3131-461A-A3E8-40AC0B1D7632} = {0786F255-C3A7-4912-A669-12273E7AE013}
{33C15AAC-6E56-477E-A118-3451FD21AC49} = {0786F255-C3A7-4912-A669-12273E7AE013}
{0518DDC0-82BC-4E7C-A24D-98B8EA9C47B3} = {C73A600E-7F50-467C-9228-58AC2C1A7DDA}
{6B00D0DE-8A17-44B8-BF47-F372E9189434} = {C73A600E-7F50-467C-9228-58AC2C1A7DDA}
{5E524D23-AD60-45AF-B279-0322941E9F31} = {6B00D0DE-8A17-44B8-BF47-F372E9189434}
{B4EF7358-C76B-4142-9746-B082114B1DDD} = {6B00D0DE-8A17-44B8-BF47-F372E9189434}
{0DD76E94-59E1-49D4-9ED7-8C696B89F26E} = {6B00D0DE-8A17-44B8-BF47-F372E9189434}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {15A17F22-F747-4B82-BF5F-E0224AF4B3ED}

Просмотреть файл

@ -14,8 +14,6 @@ stages:
displayName: Windows
pool:
vmImage: 'windows-latest'
variables:
ZLIB_ROOT: '$(Build.SourcesDirectory)\native\src\thirdparty\zlib\zlib-src'
steps:
- template: templates/windows-build.yml
parameters:
@ -35,15 +33,14 @@ stages:
g++-7 --version
which gcc-7
which g++-7
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-7 50
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-7 50
displayName: 'Install GCC 7'
- template: templates/nix-build.yml
parameters:
artifactName: linux-drop
ext: a
- job: macOs
displayName: Mac OS X
@ -54,7 +51,6 @@ stages:
- template: templates/nix-build.yml
parameters:
artifactName: macos-drop
ext: a
- job: Nuget
displayName: Pack into Nuget

Просмотреть файл

Просмотреть файл

@ -52,20 +52,10 @@ set(SEAL_ENFORCE_HE_STD_SECURITY @SEAL_ENFORCE_HE_STD_SECURITY@)
# Add the current directory to the module search path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
set(SEAL_USE_MSGSL @SEAL_USE_MSGSL@)
if(SEAL_USE_MSGSL)
find_seal_dependency(MSGSL)
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_seal_dependency(Threads)
set(SEAL_USE_ZLIB @SEAL_USE_ZLIB@)
if(SEAL_USE_ZLIB)
find_seal_dependency(ZLIB)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/SEALTargets.cmake)
if(TARGET SEAL::seal)

Просмотреть файл

@ -11,17 +11,17 @@
<PropertyGroup Condition="'$(Platform)'=='AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>../bin/$(Configuration)</OutputPath>
<OutputPath>$(ProjectDir)../../bin/dotnet/$(Configuration)</OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../src/SEALNet.csproj" />
<ProjectReference Include="$(ProjectDir)../src/SEALNet.csproj" />
</ItemGroup>
<ItemGroup>
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Windows))" Include="$(ProjectDir)..\..\native\lib\x64\$(Configuration)\sealc.dll" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Linux))" Include="$(ProjectDir)../../native/lib/libsealc.so.*" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(OSX))" Include="$(ProjectDir)../../native/lib/libsealc.*.dylib" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Windows))" Include="$(ProjectDir)..\..\lib\x64\$(Configuration)\sealc.dll" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Linux))" Include="$(ProjectDir)../../lib/libsealc.so.*" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(OSX))" Include="$(ProjectDir)../../lib/libsealc.*.dylib" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

Просмотреть файл

@ -23,12 +23,12 @@
</metadata>
<files>
<file src="SEALNet.targets" target="build/Microsoft.Research.SEALNet.targets" />
<file src="@SEAL_WINDOWS_SEAL_C_PATH@" target="runtimes/win10-x64/native" />
<file src="@SEAL_LINUX_SEAL_C_PATH@" target="runtimes/linux-x64/native" />
<file src="@SEAL_MACOS_SEAL_C_PATH@" target="runtimes/osx-x64/native" />
<file src="$LINUX_SEAL_C$" target="runtimes/linux-x64/native" />
<file src="$MACOS_SEAL_C$" target="runtimes/osx-x64/native" />
<file src="../lib/$Configuration$/netstandard2.1/SEALNet.dll" target="lib/netstandard2.1/" />
<file src="@SEAL_WINDOWS_SEAL_C_PATH@" target="runtimes/win10-x64" />
<file src="@SEAL_LINUX_SEAL_C_PATH@" target="runtimes/linux-x64" />
<file src="@SEAL_MACOS_SEAL_C_PATH@" target="runtimes/macos-x64" />
<file src="$LINUX_SEAL_C$" target="runtimes/linux-x64" />
<file src="$MACOS_SEAL_C$" target="runtimes/macos-x64" />
<file src="../../lib/dotnet/$Configuration$/netstandard2.1/SEALNet.dll" target="lib/netstandard2.1/" />
<file src="../../LICENSE" target="LICENSE" />
</files>
</package>

Просмотреть файл

@ -5,9 +5,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform('Windows'))" Include="$(MSBuildThisFileDirectory)../runtimes/win10-x64/native/sealc.dll" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform('Linux'))" Include="$(MSBuildThisFileDirectory)../runtimes/linux-x64/native/libsealc.so*" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform('OSX'))" Include="$(MSBuildThisFileDirectory)../runtimes/osx-x64/native/libsealc*.dylib" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform('Windows'))" Include="$(MSBuildThisFileDirectory)../runtimes/win10-x64/sealc.dll" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform('Linux'))" Include="$(MSBuildThisFileDirectory)../runtimes/linux-x64/libsealc.so*" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform('OSX'))" Include="$(MSBuildThisFileDirectory)../runtimes/macos-x64/libsealc*.dylib" />
</ItemGroup>
<ItemGroup>
<None Include="@(SEALCBinaryFiles)">

Просмотреть файл

@ -11,9 +11,9 @@
<DelaySign Condition="'$(OS)' == 'Windows_NT' And '$(SEALNetSigningCertificate)' != ''">true</DelaySign>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='AnyCPU'">
<DocumentationFile>../lib/$(Configuration)/SEALNet.xml</DocumentationFile>
<DocumentationFile>$(ProjectDir)../../lib/dotnet/$(Configuration)/SEALNet.xml</DocumentationFile>
<PlatformTarget>x64</PlatformTarget>
<OutputPath>../lib/$(Configuration)</OutputPath>
<OutputPath>$(ProjectDir)../../lib/dotnet/$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants />

Просмотреть файл

@ -11,7 +11,7 @@
<PropertyGroup Condition="'$(Platform)'=='AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>../lib/$(Configuration)</OutputPath>
<OutputPath>$(ProjectDir)../../bin/dotnet/$(Configuration)</OutputPath>
</PropertyGroup>
<ItemGroup>
@ -21,13 +21,13 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../src/SEALNet.csproj" />
<ProjectReference Include="$(ProjectDir)../src/SEALNet.csproj" />
</ItemGroup>
<ItemGroup>
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Windows))" Include="$(ProjectDir)..\..\native\lib\x64\$(Configuration)\sealc.dll" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Linux))" Include="$(ProjectDir)../../native/lib/libsealc.so.*" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(OSX))" Include="$(ProjectDir)../../native/lib/libsealc*.dylib" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Windows))" Include="$(ProjectDir)..\..\lib\x64\$(Configuration)\sealc.dll" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(Linux))" Include="$(ProjectDir)../../lib/libsealc.so.*" />
<SEALCBinaryFiles Condition="$([MSBuild]::IsOsPlatform(OSX))" Include="$(ProjectDir)../../lib/libsealc.*.dylib" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

Просмотреть файл

@ -1,30 +1,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.12)
project(SEALExamples VERSION 3.5.0 LANGUAGES CXX)
# Executable will be in ../bin
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SEALExamples_SOURCE_DIR}/../bin)
add_executable(sealexamples examples.cpp)
target_sources(sealexamples
PRIVATE
1_bfv_basics.cpp
2_encoders.cpp
3_levels.cpp
4_ckks_basics.cpp
5_rotation.cpp
6_serialization.cpp
7_performance.cpp
)
# Import Microsoft SEAL
find_package(SEAL 3.5.0 EXACT REQUIRED
# Providing a path so this can be built without installing Microsoft SEAL
PATHS ${SEALExamples_SOURCE_DIR}/../src/cmake
)
# Link Microsoft SEAL
target_link_libraries(sealexamples SEAL::seal)
${CMAKE_CURRENT_LIST_DIR}/examples.cpp
${CMAKE_CURRENT_LIST_DIR}/1_bfv_basics.cpp
${CMAKE_CURRENT_LIST_DIR}/2_encoders.cpp
${CMAKE_CURRENT_LIST_DIR}/3_levels.cpp
${CMAKE_CURRENT_LIST_DIR}/4_ckks_basics.cpp
${CMAKE_CURRENT_LIST_DIR}/5_rotation.cpp
${CMAKE_CURRENT_LIST_DIR}/6_serialization.cpp
${CMAKE_CURRENT_LIST_DIR}/7_performance.cpp
)

Просмотреть файл

@ -71,25 +71,25 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealexamples</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealexamples</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealexamples</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealexamples</TargetName>
</PropertyGroup>
@ -100,7 +100,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_ENABLE_EXTENDED_ALIGNED_STORAGE</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)native\src</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)native\src</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<ControlFlowGuard>Guard</ControlFlowGuard>
@ -110,7 +110,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
@ -121,7 +121,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_ENABLE_EXTENDED_ALIGNED_STORAGE</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)native\src</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)native\src</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<ControlFlowGuard>Guard</ControlFlowGuard>
@ -131,7 +131,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
@ -144,7 +144,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_ENABLE_EXTENDED_ALIGNED_STORAGE</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)native\src</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)native\src</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<ControlFlowGuard>Guard</ControlFlowGuard>
@ -155,7 +155,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Profile>true</Profile>
</Link>
@ -169,7 +169,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_ENABLE_EXTENDED_ALIGNED_STORAGE</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)native\src</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)native\src</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<ControlFlowGuard>Guard</ControlFlowGuard>
@ -180,7 +180,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Profile>true</Profile>
</Link>

Просмотреть файл

@ -212,7 +212,7 @@ inline void print_matrix(std::vector<T> matrix, std::size_t row_size)
std::cout << std::setw(3) << matrix[i] << ((i != 2 * row_size - 1) ? "," : " ]\n");
}
std::cout << std::endl;
};
}
/*
Helper function: Print line number.
@ -220,4 +220,4 @@ Helper function: Print line number.
inline void print_line(int line_number)
{
std::cout << "Line " << std::setw(3) << line_number << " --> ";
}
}

Просмотреть файл

@ -51,7 +51,33 @@ if "%VSVERSION%"=="15.0" (
exit 1
)
set CONFIGDIR=".config\%VSVERSION%\%PROJECTPLATFORM%"
rem Download Microsoft GSL
set MSGSLCONFIGDIR="..\..\thirdparty\msgsl\.config\%VSVERSION%\%PROJECTPLATFORM%"
cd %~dp0
if not exist %MSGSLCONFIGDIR% (
mkdir %MSGSLCONFIGDIR%
)
cd %MSGSLCONFIGDIR%
"%CMAKEPATH%" ..\..\.. -G %CMAKEGEN% -A %PROJECTPLATFORM%
"%CMAKEPATH%" --build . --config "%PROJECTCONFIGURATION%"
rem Copy Microsoft GSL header files into the local source directory
robocopy ..\..\..\GSL-src\include %~dp0 /s
rem Download and build ZLIB
set ZLIBCONFIGDIR="..\..\thirdparty\zlib\.config\%VSVERSION%\%PROJECTPLATFORM%"
cd %~dp0
if not exist %ZLIBCONFIGDIR% (
mkdir %ZLIBCONFIGDIR%
)
cd %ZLIBCONFIGDIR%
"%CMAKEPATH%" ..\..\.. -G %CMAKEGEN% -A %PROJECTPLATFORM% ^
-DZLIB_PLATFORM="%PROJECTPLATFORM%"
"%CMAKEPATH%" --build . --config "%PROJECTCONFIGURATION%"
rem Configure Microsoft SEAL
set CONFIGDIR="..\..\.config\%VSVERSION%\%PROJECTPLATFORM%"
cd %~dp0
if not exist %CONFIGDIR% (
mkdir %CONFIGDIR%
@ -59,27 +85,13 @@ if not exist %CONFIGDIR% (
cd %CONFIGDIR%
echo Running CMake configuration in %cd%
rem Determine if ZLIB should be enabled
set USE_ZLIB=0
if defined ZLIB_ROOT (
set USE_ZLIB=1
)
rem Determine if MSGSL should be enabled
set USE_MSGSL=0
if defined MSGSL_ROOT (
set USE_MSGSL=1
)
rem Call CMake.
"%CMAKEPATH%" ..\..\.. ^
-G %CMAKEGEN% ^
-A %PROJECTPLATFORM% ^
"%CMAKEPATH%" ..\..\.. -G %CMAKEGEN% -A %PROJECTPLATFORM% ^
-DALLOW_COMMAND_LINE_BUILD=1 ^
-DCMAKE_BUILD_TYPE="%PROJECTCONFIGURATION%" ^
-DSEAL_USE_MSGSL=%USE_MSGSL% ^
-DMSGSL_ROOT="%MSGSL_ROOT%" ^
-DSEAL_USE_ZLIB=%USE_ZLIB% ^
-DZLIB_ROOT="%ZLIB_ROOT%" ^
-DCMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="Release" ^
-DBUILD_SHARED_LIBS=OFF ^
-DSEAL_USE_MSGSL=ON ^
-DSEAL_USE_ZLIB=ON ^
-DSEAL_BUILD_TESTS=OFF ^
-DSEAL_BUILD_EXAMPLES=OFF ^
-DSEAL_BUILD_SEAL_C=OFF ^
--no-warn-unused-cli

Просмотреть файл

@ -118,7 +118,6 @@
<ClCompile Include="seal\util\uintcore.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
<Text Include="seal\CMakeLists.txt" />
<Text Include="seal\util\CMakeLists.txt" />
</ItemGroup>
@ -186,35 +185,43 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\sealc\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\</IntDir>
<TargetExt>.lib</TargetExt>
<TargetName>seal</TargetName>
<ExtensionsToDeleteOnClean>
</ExtensionsToDeleteOnClean>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\sealc\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\</IntDir>
<TargetExt>.lib</TargetExt>
<TargetName>seal</TargetName>
<ExtensionsToDeleteOnClean>
</ExtensionsToDeleteOnClean>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\sealc\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\</IntDir>
<TargetExt>.lib</TargetExt>
<TargetName>seal</TargetName>
<ExtensionsToDeleteOnClean>
</ExtensionsToDeleteOnClean>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\sealc\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\</IntDir>
<TargetExt>.lib</TargetExt>
<TargetName>seal</TargetName>
<ExtensionsToDeleteOnClean>
</ExtensionsToDeleteOnClean>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ZLIB_ROOT);$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/thirdparty/zlib/zlib-src;$(SolutionDir)/thirdparty/zlib/zlib-build/$(Platform);$(ProjectDir)</AdditionalIncludeDirectories>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -236,8 +243,8 @@
<Message>Configure Microsoft SEAL through CMake</Message>
</PreBuildEvent>
<Lib>
<AdditionalDependencies>Bcrypt.lib;$(ZlibName)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_ROOT)\Release</AdditionalLibraryDirectories>
<AdditionalDependencies>Bcrypt.lib;zlibstaticd.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\thirdparty\zlib\zlib-build\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4006 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
@ -246,7 +253,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ZLIB_ROOT);$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/thirdparty/zlib/zlib-src;$(SolutionDir)/thirdparty/zlib/zlib-build/$(Platform);$(ProjectDir)</AdditionalIncludeDirectories>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -267,8 +274,8 @@
<Message>Configure Microsoft SEAL through CMake</Message>
</PreBuildEvent>
<Lib>
<AdditionalDependencies>Bcrypt.lib;$(ZlibName)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_ROOT)\Release</AdditionalLibraryDirectories>
<AdditionalDependencies>Bcrypt.lib;zlibstaticd.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\thirdparty\zlib\zlib-build\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4006 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
@ -279,7 +286,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ZLIB_ROOT);$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/thirdparty/zlib/zlib-src;$(SolutionDir)/thirdparty/zlib/zlib-build/$(Platform);$(ProjectDir)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -302,8 +309,8 @@
<Message>Configure Microsoft SEAL through CMake</Message>
</PreBuildEvent>
<Lib>
<AdditionalDependencies>Bcrypt.lib;$(ZlibName)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_ROOT)\Release</AdditionalLibraryDirectories>
<AdditionalDependencies>Bcrypt.lib;zlibstatic.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\thirdparty\zlib\zlib-build\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4006 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
@ -314,7 +321,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ZLIB_ROOT);$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/thirdparty/zlib/zlib-src;$(SolutionDir)/thirdparty/zlib/zlib-build/$(Platform);$(ProjectDir)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<LanguageStandard>stdcpp17</LanguageStandard>
@ -336,8 +343,8 @@
<Message>Configure Microsoft SEAL through CMake</Message>
</PreBuildEvent>
<Lib>
<AdditionalDependencies>Bcrypt.lib;$(ZlibName)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_ROOT)\Release</AdditionalLibraryDirectories>
<AdditionalDependencies>Bcrypt.lib;zlibstatic.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\thirdparty\zlib\zlib-build\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4006 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>

Просмотреть файл

@ -318,9 +318,6 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt">
<Filter>Other</Filter>
</Text>
<Text Include="seal\CMakeLists.txt">
<Filter>Other\seal</Filter>
</Text>
@ -342,4 +339,4 @@
<Filter>Other</Filter>
</None>
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -73,27 +73,27 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<TargetName>sealc</TargetName>
<IntDir>$(ProjectDir)obj\seal\$(Platform)\$(Configuration)\</IntDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\c\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<TargetName>sealc</TargetName>
<IntDir>$(ProjectDir)obj\seal\$(Platform)\$(Configuration)\</IntDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\c\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<TargetName>sealc</TargetName>
<IntDir>$(ProjectDir)obj\seal\$(Platform)\$(Configuration)\</IntDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\c\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration)\</OutDir>
<TargetName>sealc</TargetName>
<IntDir>$(ProjectDir)obj\seal\$(Platform)\$(Configuration)\</IntDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\seal\c\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@ -105,11 +105,12 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>SEAL_C_EXPORTS;NOMINMAX;_ENABLE_EXTENDED_ALIGNED_STORAGE;_SCL_SECURE_NO_WARNING;NDEBUG;SEALDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<PrecompiledHeaderFile>seal\c/stdafx.h</PrecompiledHeaderFile>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -117,7 +118,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>seal.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -130,11 +131,12 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>SEAL_C_EXPORTS;NOMINMAX;_ENABLE_EXTENDED_ALIGNED_STORAGE;_SCL_SECURE_NO_WARNING;NDEBUG;SEALDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<PrecompiledHeaderFile>seal\c\stdafx.h</PrecompiledHeaderFile>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -142,7 +144,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>seal.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -153,17 +155,19 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>SEAL_C_EXPORTS;NOMINMAX;_ENABLE_EXTENDED_ALIGNED_STORAGE;_SCL_SECURE_NO_WARNING;_DEBUG;SEALDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<PrecompiledHeaderFile>seal\c\stdafx.h</PrecompiledHeaderFile>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>seal.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -174,17 +178,19 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>SEAL_C_EXPORTS;NOMINMAX;_ENABLE_EXTENDED_ALIGNED_STORAGE;_SCL_SECURE_NO_WARNING;_DEBUG;SEALDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(ProjectDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<PrecompiledHeaderFile>seal\c\stdafx.h</PrecompiledHeaderFile>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>seal.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

Просмотреть файл

@ -196,7 +196,7 @@ namespace seal
// Note: We already performed bit-reversal when reading in the matrix
inverse_ntt_negacyclic_harvey(destination.data(), *context_data.plain_ntt_tables());
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
void BatchEncoder::encode(gsl::span<const uint64_t> values_matrix, Plaintext &destination)
{
auto &context_data = *context_->first_context_data();
@ -418,7 +418,7 @@ namespace seal
: static_cast<int64_t>(curr_value);
}
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
void BatchEncoder::decode(const Plaintext &plain, gsl::span<uint64_t> destination, MemoryPoolHandle pool)
{
if (!is_valid_for(plain, context_))

Просмотреть файл

@ -11,7 +11,7 @@
#include "seal/util/uintcore.h"
#include <limits>
#include <vector>
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
#include <gsl/span>
#endif
@ -101,7 +101,7 @@ namespace seal
@throws std::invalid_argument if values is too large
*/
void encode(const std::vector<std::int64_t> &values, Plaintext &destination);
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Creates a plaintext from a given matrix. This function "batches" a given matrix
of integers modulo the plaintext modulus into a plaintext element, and stores
@ -194,7 +194,7 @@ namespace seal
void decode(
const Plaintext &plain, std::vector<std::int64_t> &destination,
MemoryPoolHandle pool = MemoryManager::GetPool());
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Inverse of encode. This function "unbatches" a given plaintext into a matrix
of integers modulo the plaintext modulus, and stores the result in the destination

Просмотреть файл

@ -44,7 +44,7 @@ namespace seal
throw invalid_argument("value must be non-null for non-zero bit count");
}
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
BigUInt::BigUInt(gsl::span<uint64_t> value)
{
if (unsigned_gt(value.size(), numeric_limits<int>::max() / bits_per_uint64))

Просмотреть файл

@ -15,7 +15,7 @@
#include <cstdint>
#include <iostream>
#include <string>
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
#include <gsl/span>
#endif
@ -149,7 +149,7 @@ namespace seal
and bit_count is positive
*/
BigUInt(int bit_count, std::uint64_t *value);
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Creates an aliased BigUInt with given backing array and bit width set to
the size of the backing array. An aliased BigUInt does not internally
@ -238,7 +238,7 @@ namespace seal
{
return value_.get();
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Returns the backing array storing the BigUInt value.
@ -419,7 +419,7 @@ namespace seal
value_ = util::Pointer<std::uint64_t>::Aliasing(value);
bit_count_ = bit_count;
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Makes the BigUInt an aliased BigUInt with the given backing array
and bit width set equal to the size of the backing array. An aliased

Просмотреть файл

@ -15,7 +15,7 @@
#include <memory>
#include <type_traits>
#include <vector>
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
#include <gsl/span>
#endif
@ -138,7 +138,7 @@ namespace seal
{
encode(values, context_->first_parms_id(), scale, destination, std::move(pool));
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Encodes a vector of double-precision floating-point real or complex numbers
into a plaintext polynomial. Append zeros if vector size is less than N/2.
@ -359,7 +359,7 @@ namespace seal
destination.resize(slots_);
decode_internal(plain, destination.data(), std::move(pool));
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Decodes a plaintext polynomial into double-precision floating-point
real or complex numbers. Dynamic memory allocations in the process are

Просмотреть файл

@ -282,7 +282,7 @@ namespace seal
{
Ciphertext destination;
encrypt_internal(plain, false, true, destination, pool);
return std::move(destination);
return destination;
}
/**
@ -310,7 +310,7 @@ namespace seal
{
Ciphertext destination;
encrypt_zero_internal(parms_id, false, true, destination, pool);
return std::move(destination);
return destination;
}
/**

Просмотреть файл

@ -13,7 +13,7 @@
#include <iostream>
#include <limits>
#include <type_traits>
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
#include <gsl/span>
#endif
@ -239,7 +239,7 @@ namespace seal
{
return size_ ? cbegin() + size_ : cbegin();
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Returns a span pointing to the beginning of the IntArray.
*/

Просмотреть файл

@ -18,7 +18,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
#include <gsl/span>
#endif
@ -346,7 +346,7 @@ namespace seal
{
return data_.cbegin();
}
#ifdef SEAL_USE_MSGSL_SPAN
#ifdef SEAL_USE_MSGSL
/**
Returns a span pointing to the beginning of the text polynomial.
*/

Просмотреть файл

@ -23,5 +23,4 @@
#cmakedefine SEAL_USE__ADDCARRY_U64
#cmakedefine SEAL_USE__SUBBORROW_U64
#cmakedefine SEAL_USE_MSGSL
#cmakedefine SEAL_USE_MSGSL_SPAN
#cmakedefine SEAL_USE_ZLIB

12
native/src/thirdparty/zlib/CMakeLists.txt поставляемый
Просмотреть файл

@ -1,12 +0,0 @@
cmake_minimum_required(VERSION 3.12)
project(ZLIB VERSION 1.2.11 LANGUAGES CXX C)
include(ExternalProject)
ExternalProject_Add(zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.11
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-src"
INSTALL_COMMAND ""
)

Просмотреть файл

@ -1,36 +1,5 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.12)
project(SEALTest LANGUAGES CXX)
# Executable will be in ../bin
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SEALTest_SOURCE_DIR}/../bin)
add_executable(sealtest seal/testrunner.cpp)
# Import Microsoft SEAL
find_package(SEAL 3.5.0 EXACT REQUIRED
# Providing a path so this can be built without installing Microsoft SEAL
PATHS ${SEALTest_SOURCE_DIR}/../src/cmake
)
# Add source files
add_subdirectory(seal)
# Only build GTest
option(BUILD_GMOCK OFF)
option(INSTALL_GTEST OFF)
mark_as_advanced(BUILD_GMOCK INSTALL_GTEST)
# Add GTest
set(GTEST_DIR ${SEALTest_SOURCE_DIR}/thirdparty/googletest)
if(NOT EXISTS ${GTEST_DIR}/CMakeLists.txt)
message(FATAL_ERROR "Could not find `${GTEST_DIR}/CMakeLists.txt`. Run `git submodule update --init` and retry.")
endif()
add_subdirectory(${GTEST_DIR})
# Link Microsoft SEAL and GTest
target_link_libraries(sealtest SEAL::seal gtest)
add_subdirectory(seal)

Просмотреть файл

@ -33,22 +33,22 @@
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealtest</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealtest</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealtest</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(ProjectDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
<TargetName>sealtest</TargetName>
</PropertyGroup>
@ -117,7 +117,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ControlFlowGuard>Guard</ControlFlowGuard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
@ -127,7 +127,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -139,7 +139,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ControlFlowGuard>Guard</ControlFlowGuard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
@ -149,7 +149,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -159,7 +159,7 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ControlFlowGuard>Guard</ControlFlowGuard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
@ -171,7 +171,7 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -181,7 +181,7 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(MSGSL_ROOT);$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)/native/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ControlFlowGuard>Guard</ControlFlowGuard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
@ -193,7 +193,7 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalDependencies>seal.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
target_sources(sealtest
target_sources(sealtests
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/batchencoder.cpp
${CMAKE_CURRENT_LIST_DIR}/biguint.cpp
@ -25,6 +25,7 @@ target_sources(sealtest
${CMAKE_CURRENT_LIST_DIR}/secretkey.cpp
${CMAKE_CURRENT_LIST_DIR}/serialization.cpp
${CMAKE_CURRENT_LIST_DIR}/smallmodulus.cpp
${CMAKE_CURRENT_LIST_DIR}/testrunner.cpp
)
add_subdirectory(util)

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
target_sources(sealtest
target_sources(sealtests
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/baseconverter.cpp
${CMAKE_CURRENT_LIST_DIR}/clipnormal.cpp

1
native/tests/thirdparty/googletest поставляемый

@ -1 +0,0 @@
Subproject commit 7f1c0f6f8122d7978c9de29d9d468f7fac9ba62c

Просмотреть файл

@ -1,53 +1,24 @@
parameters:
artifactName: 'nix-drop'
ext: ''
steps:
- task: CMake@1
displayName: 'CMake ZLIB'
inputs:
workingDirectory: native/src/thirdparty/zlib
cmakeArgs: '-DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON'
- task: CMake@1
displayName: 'Build ZLIB'
inputs:
workingDirectory: native/src/thirdparty/zlib
cmakeArgs: '--build'
- task: CMake@1
displayName: 'CMake SEAL'
inputs:
workingDirectory: native/src
cmakeArgs: '-DCMAKE_BUILD_TYPE=Release -DSEAL_BUILD_SEAL_C=ON -DZLIB_LIBRARY=./thirdparty/zlib/zlib-src/libz.${{parameters.ext}} -DZLIB_INCLUDE_DIR=./thirdparty/zlib/zlib-src/}'
workingDirectory: '$(Build.SourcesDirectory)'
cmakeArgs: '-DCMAKE_BUILD_TYPE=Release -DSEAL_BUILD_TESTS=ON -DSEAL_BUILD_SEAL_C=ON .'
- task: CMake@1
- script: |
cd $BUILD_SOURCESDIRECTORY
make
displayName: 'Build SEAL'
inputs:
workingDirectory: native/src
cmakeArgs: '--build'
- script: |
cd native/tests/thirdparty
git submodule update --init
displayName: 'Install Google Test'
- task: CMake@1
displayName: 'CMake SEALTest'
inputs:
workingDirectory: native/tests
cmakeArgs: '-DSEAL_DIR=../src/cmake}'
- task: CMake@1
displayName: 'Build SEALTest'
inputs:
workingDirectory: native/tests
cmakeArgs: '--build}'
- script: |
cd $BUILD_SOURCESDIRECTORY
cd native/bin
./sealtest
./bin/sealtests
displayName: 'Run unit tests'
- task: UseDotNet@2
@ -66,12 +37,12 @@ steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/native/lib'
SourceFolder: '$(Build.SourcesDirectory)/lib'
Contents: 'libsealc.*'
TargetFolder: '$(Build.ArtifactStagingDirectory)/native/lib'
TargetFolder: '$(Build.ArtifactStagingDirectory)/lib'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: ${{ parameters.artifactName }}
artifactName: ${{ parameters.artifactName }}

Просмотреть файл

@ -37,16 +37,16 @@ steps:
- task: CopyFiles@2
displayName: 'Copy Linux Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)\linux-drop\dotnet\lib\'
SourceFolder: '$(Build.ArtifactStagingDirectory)\linux-drop\lib\'
Contents: '*'
TargetFolder: '$(Build.ArtifactStagingDirectory)\windows-drop\dotnet\lib\'
TargetFolder: '$(Build.ArtifactStagingDirectory)\windows-drop\lib\'
- task: CopyFiles@2
displayName: 'Copy Mac OS X Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)\macos-drop\dotnet\lib\'
SourceFolder: '$(Build.ArtifactStagingDirectory)\macos-drop\lib\'
Contents: '*'
TargetFolder: '$(Build.ArtifactStagingDirectory)\windows-drop\dotnet\lib\'
TargetFolder: '$(Build.ArtifactStagingDirectory)\windows-drop\lib\'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
@ -59,9 +59,9 @@ steps:
command: 'pack'
packagesToPack: '$(Build.ArtifactStagingDirectory)\windows-drop\dotnet\nuget\*.nuspec'
packDestination: '$(Build.ArtifactStagingDirectory)\windows-drop\dotnet\nuget\Release'
buildProperties: 'Configuration=Release;LINUX_SEALNETNATIVE=$(Build.ArtifactStagingDirectory)\windows-drop\dotnet\lib\libsealnetnative.so;MACOS_SEALNETNATIVE=$(Build.ArtifactStagingDirectory)\windows-drop\dotnet\lib\libsealnetnative.dylib'
buildProperties: 'Configuration=Release;LINUX_SEAL_C=$(Build.ArtifactStagingDirectory)\windows-drop\lib\libsealc.so*;MACOS_SEAL_C=$(Build.ArtifactStagingDirectory)\windows-drop\lib\libsealc*.dylib'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
PathtoPublish: '$(Build.ArtifactStagingDirectory)'

Просмотреть файл

@ -3,7 +3,6 @@ parameters:
configuration: 'release'
steps:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
inputs:
@ -28,18 +27,6 @@ steps:
outputFormat: sarif
debugMode: false
- task: CMake@1
displayName: 'CMake ZLIB'
inputs:
workingDirectory: native/src/thirdparty/zlib
cmakeArgs: '-DCMAKE_POSITION_INDEPENDENT_CODE=ON .'
- task: CMake@1
displayName: 'Build ZLIB'
inputs:
workingDirectory: native/src/thirdparty/zlib
cmakeArgs: '--build . --config Release'
- task: PowerShell@2
displayName: 'Download Strong Name certificate'
inputs:
@ -50,7 +37,7 @@ steps:
if (Test-Path env:SEALNetSigningCertificate) {
Invoke-WebRequest -Uri "$env:SEALNetSigningCertificate" -OutFile $CertOutFile
}
- task: UseDotNet@2
displayName: 'Get .NET Core 3.1 SDK'
inputs:

19
thirdparty/googletest/CMakeLists.txt поставляемый Normal file
Просмотреть файл

@ -0,0 +1,19 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.12)
project(GoogleTest NONE)
include(ExternalProject)
ExternalProject_Add(googletest_external
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/googletest-src
BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/googletest-build
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

26
thirdparty/msgsl/CMakeLists.txt поставляемый Normal file
Просмотреть файл

@ -0,0 +1,26 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.12)
project(GSL VERSION 2.1.0 LANGUAGES CXX C)
include(ExternalProject)
ExternalProject_Add(msgsl_external
GIT_REPOSITORY https://github.com/microsoft/GSL.git
GIT_TAG v2.1.0
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/GSL-src
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DGSL_TEST=OFF
INSTALL_COMMAND ""
TEST_COMMAND ""
)
# Install the header files
if(SEAL_USE_MSGSL)
install(
DIRECTORY
${CMAKE_CURRENT_LIST_DIR}/GSL-src/include/gsl
DESTINATION
${SEAL_INCLUDES_INSTALL_DIR}
)
endif()

23
thirdparty/zlib/CMakeLists.txt поставляемый Normal file
Просмотреть файл

@ -0,0 +1,23 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required(VERSION 3.12)
project(ZLIB VERSION 1.2.11 LANGUAGES CXX C)
if(MSVC)
set(ZLIB_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/zlib-build/${ZLIB_PLATFORM})
else()
set(ZLIB_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/zlib-src)
endif()
include(ExternalProject)
ExternalProject_Add(zlib_external
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.11
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/zlib-src
BINARY_DIR ${ZLIB_BINARY_DIR}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSKIP_INSTALL_ALL=ON
INSTALL_COMMAND ""
TEST_COMMAND ""
)