Skip to content

Commit

Permalink
Automatic linking with SEAL and eigen in extern through CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
deevashwer committed Aug 20, 2020
1 parent 3261597 commit 7fdac00
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 36 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Build Directory
build/
bin/

# Vim c_tags files
c_*
17 changes: 7 additions & 10 deletions SCI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
cmake_minimum_required (VERSION 3.0)

# Set paths to GNU gcc and g++ on Mac OS X
set(MAC_GCC "/usr/local/bin/gcc-9")
set(MAC_GPP "/usr/local/bin/g++-9")

if(APPLE)
set(CMAKE_C_COMPILER "/usr/local/bin/gcc-9")
set(CMAKE_CXX_COMPILER "/usr/local/bin/g++-9")
set(CMAKE_C_COMPILER ${MAC_GCC})
set(CMAKE_CXX_COMPILER ${MAC_GPP})
endif()

project (SCI)
Expand All @@ -17,14 +21,7 @@ message(STATUS "Option: BUILD_NETWORKS = ${BUILD_NETWORKS}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

set(CMAKE_PREFIX_PATH
${CMAKE_CURRENT_SOURCE_DIR}/extern/SEAL/native/src
${CMAKE_CURRENT_SOURCE_DIR}/extern/eigen/build)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/extern/SEAL/native/src
${CMAKE_CURRENT_SOURCE_DIR}/extern/eigen)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
Expand Down
2 changes: 1 addition & 1 deletion SCI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This directory contains the code for the Secure and Correct Inference (SCI) libr
- SEAL 3.3.2
- Eigen 3.3

SEAL and Eigen are included in `extern/` to be compiled and installed. The other packages can be installed directly using `sudo apt-get install <package>` on Linux.
SEAL and Eigen are included in `extern/` and are automatically compiled and installed. The other packages can be installed directly using `sudo apt-get install <package>` on Linux.

## Compilation

Expand Down
2 changes: 1 addition & 1 deletion SCI/extern/eigen
Submodule eigen updated from 0dd964 to 603e21
20 changes: 0 additions & 20 deletions SCI/setup_external_deps.sh

This file was deleted.

47 changes: 43 additions & 4 deletions SCI/src/LinearHE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
find_package(SEAL 3.3.2 EXACT REQUIRED)
find_package(OpenMP REQUIRED)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
# set(CMAKE_FIND_DEBUG_MODE 1)

find_package(SEAL 3.3.2 EXACT QUIET)
if (NOT SEAL_FOUND)
message(STATUS "SEAL 3.3.2 was not found: clone and install SEAL locally")
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/SEAL/native/src/CMakeLists.txt")
find_package(Git REQUIRED)
message(STATUS "initialize Git submodule: extern/SEAL")
execute_process(COMMAND git submodule update --init --recursive extern/SEAL
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
endif ()
if(APPLE)
execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/build .
-DCMAKE_C_COMPILER=${MAC_GCC} -DCMAKE_CXX_COMPILER=${MAC_GPP}
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/extern/SEAL/native/src")
else ()
execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/build .
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/extern/SEAL/native/src")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build . --target install
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/extern/SEAL/native/src")
find_package(SEAL 3.3.2 EXACT REQUIRED PATHS "${PROJECT_SOURCE_DIR}/build/")
endif ()

find_package(Eigen3 3.3 NO_MODULE QUIET)
if (NOT Eigen3_FOUND)
message(STATUS "Eigen 3.3 was not found: clone and install Eigen3 locally")
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/eigen/CMakeLists.txt")
find_package(Git REQUIRED)
message(STATUS "initialize Git submodule: extern/eigen")
execute_process(COMMAND git submodule update --init --recursive extern/eigen
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
endif ()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory build
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/extern/eigen/")
execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/build ..
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/extern/eigen/build")
execute_process(COMMAND ${CMAKE_COMMAND} --build .. --target install
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/extern/eigen/build")
message(STATUS "${PROJECT_SOURCE_DIR}")
find_package(Eigen3 3.3 REQUIRED NO_MODULE PATHS "${PROJECT_SOURCE_DIR}/build/")
endif ()

add_library(SCI-LinearHE
conv-field.cpp
Expand All @@ -10,11 +50,10 @@ add_library(SCI-LinearHE
)

target_link_libraries(SCI-LinearHE
PRIVATE
PUBLIC
SCI-utils
SEAL::seal
OpenMP::OpenMP_CXX
PUBLIC
Eigen3::Eigen
)

Expand Down

0 comments on commit 7fdac00

Please sign in to comment.