Skip to content

Commit

Permalink
Fixed problem with install on non-android devices. Fixed issue with A…
Browse files Browse the repository at this point in the history
…BY downloading old OTExtension and Encrypto_utils projects (now downloading master by default). Fixed issue with redownloading OTExtension and Encrypto_utils dependencies when cloning with git --recursive.
  • Loading branch information
oliver-schick committed Feb 9, 2020
1 parent da9d860 commit afd317e
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 65 deletions.
15 changes: 9 additions & 6 deletions cmake/Modules/FetchHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ macro(fetch_helper content_name)
set(${content_name}_DOWNLOAD_DIR_COMMAND "")
endif()
if(NOT ${${content_name}_SOURCE} STREQUAL "")
set(${content_name}_URL_COMMAND URL ${${content_name}_SOURCE})
set(${content_name}_URL_HASH_COMMAND "")
set(${content_name}_DOWNLOAD_COMMAND1 URL ${${content_name}_SOURCE})
set(${content_name}_DOWNLOAD_COMMAND2 "")
elseif(DOWNLOAD_${content_name})
set(${content_name}_DOWNLOAD_COMMAND1 URL ${${content_name}_URL})
set(${content_name}_DOWNLOAD_COMMAND2 URL_HASH ${${content_name}_URL_HASH})
else()
set(${content_name}_URL_COMMAND URL ${${content_name}_URL})
set(${content_name}_URL_HASH_COMMAND URL_HASH ${${content_name}_URL_HASH})
set(${content_name}_DOWNLOAD_COMMAND1 GIT_REPOSITORY ${${content_name}_REPOSITORY})
set(${content_name}_DOWNLOAD_COMMAND2 GIT_TAG ${${content_name}_TAG})
endif()
include(FetchContent)
FetchContent_Declare(${content_name}
${${content_name}_URL_COMMAND}
${${content_name}_URL_HASH_COMMAND}
${${content_name}_DOWNLOAD_COMMAND1}
${${content_name}_DOWNLOAD_COMMAND2}
${${content_name}_DOWNLOAD_DIR_COMMAND}
)
FetchContent_GetProperties(${content_name})
Expand Down
6 changes: 2 additions & 4 deletions src/abycore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
set(INSTALL_NAME ${PROJECT_NAME})

if(ANDROID)
set(INSTALL_BOOST_DEPENDENCIES TRUE)
if(ANDROID_ARM_NEON)
set(ABY_INSTALL_PREFIX "platforms/${ANDROID_PLATFORM}/arch-${ANDROID_SYSROOT_ABI}/NEON")
else(ANDROID_ARM_NEON)
Expand All @@ -16,12 +15,11 @@ if(ANDROID)
set(ABY_INSTALL_ARCHIVE "${ABY_INSTALL_PREFIX}/lib")
set(ABY_INSTALL_CONFIG "usr/local")
else(ANDROID)
set(INSTALL_BOOST_DEPENDENCIES FALSE)
set(ABY_INSTALL_PREFIX "")
set(ABY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(ABY_INSTALL_INCLUDE "include")
set(ABY_INSTALL_LIB "lib")
set(ABY_INSTALL_ARCHIVE "lib")
set(ABY_INSTALL_CONFIG "usr/local")
set(ABY_INSTALL_CONFIG "${CMAKE_INSTALL_PREFIX}")
endif(ANDROID)


Expand Down
2 changes: 2 additions & 0 deletions src/abycore/cmake/Modules/AddBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ if(NOT TARGET Boost::boost OR NOT TARGET Boost::filesystem)
message(STATUS "Fetching Boost sources. This might take several minutes. "
"No progress is shown, please wait...")
include(AddBOOST_CMAKE)
set(INSTALL_BOOST_DEPENDENCIES TRUE)
elseif(ANDROID AND NOT DOWNLOAD_BOOST AND EXISTS BOOST_SOURCE)
include(AddBOOST_CMAKE)
set(INSTALL_BOOST_DEPENDENCIES TRUE)
elseif(ANDROID)
message(FATAL_ERROR "Please provide a valid directory for BOOST_SOURCE (recommended) or automatically download boost libraries by setting DOWNLOAD_BOOST.")
else()
Expand Down
5 changes: 1 addition & 4 deletions src/abycore/cmake/Modules/AddENCRYPTO_utils.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.13)

find_package(ENCRYPTO_utils QUIET)
if(ENCRYPTO_utils_FOUND)
message(STATUS "Found ENCRYPTO_utils.")
elseif(NOT ENCRYPTO_utils_FOUND AND NOT TARGET ENCRYPTO_utils::encrypto_utils)
if(NOT TARGET ENCRYPTO_utils::encrypto_utils)
if(NOT ENCRYPTO_utils_LIBRARY_TYPE)
set(ENCRYPTO_utils_LIBRARY_TYPE ${ABY_LIBRARY_TYPE})
endif()
Expand Down
18 changes: 11 additions & 7 deletions src/abycore/cmake/Modules/AddGMP.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.13)

option(BUILD_GMP "Compile GMP library if none is found." OFF)
option(FORCE_GMP_BUILD "Force Build of GMP library (use if installed GMP library is incompatible with build)." OFF)
option(BUILD_GMP "Build GMP library if none is found." OFF)
option(FORCE_GMP_BUILD "Force building of GMP library (use if installed GMP library is incompatible with build)." OFF)
set(GMP_LIB_DIR "" CACHE PATH "Path to GMP library.")
set(GMP_INCLUDE_DIR "" CACHE PATH "Path to GMP include directories.")
set(GMP_INCLUDES "" CACHE PATH "Path to GMP include directories.")
set(GMP_SOURCE CACHE PATH "Path to GMP source (If building GMP).")
set(GMP_URL https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz CACHE STRING "URL of GMP source.")
set(GMP_URL_HASH SHA256=12fed0532d440d2dc902e64f016aa89a33af6044b90bd1f7bca7396635105dbb CACHE STRING "Hash of GMP source archive.")
Expand Down Expand Up @@ -42,13 +42,17 @@ if(NOT GMP_FOUND OR NOT GMPXX_FOUND)
message(STATUS "Adding GMP and GMPXX library to build.")
set(GMP_ONLY OFF)
include(BuildGMP)
set(GMP_INCLUDES ${GMP_INCLUDE_DIR})
elseif(NOT EXISTS "${GMP_LIB_DIR}/${GMP_LIBRARY_NAME}" OR
NOT EXISTS "${GMP_LIB_DIR}/${GMPXX_LIBRARY_NAME}" OR
NOT EXISTS "${GMP_INCLUDE_DIR}/gmp.h" OR
NOT EXISTS "${GMP_INCLUDE_DIR}/gmpxx.h")
message(FATAL_ERROR " Did not find gmp in standard location."
" Either set GMP_LIB_DIR and GMP_INCLUDE_DIR to valid locations"
NOT EXISTS "${GMP_INCLUDES}/gmp.h" OR
NOT EXISTS "${GMP_INCLUDES}/gmpxx.h")
message(FATAL_ERROR "Did not find gmp in standard location."
" Either set GMP_LIB_DIR and GMP_INCLUDES to valid locations"
" or enable GMP build by setting BUILD_GMP. ")
else()
set(GMP_LIB_DIR ${GMP_LIBRARY_DIR})
set(GMP_INCLUDE_DIR ${GMP_INCLUDES})
endif()
include(InstallConfig)
install_config(IGNORED "GMP" "${ABY_INSTALL_CONFIG}")
Expand Down
5 changes: 1 addition & 4 deletions src/abycore/cmake/Modules/AddOTExtension.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.13)

find_package(OTExtension QUIET)
if(OTExtension_FOUND)
message(STATUS "Found OTExtension.")
elseif(NOT OTExtension_FOUND AND NOT TARGET OTExtension::otextension)
if(NOT TARGET OTExtension::otextension)
if(NOT OTExtension_LIBRARY_TYPE)
set(OTExtension_LIBRARY_TYPE ${ABY_LIBRARY_TYPE})
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/abycore/cmake/Modules/BuildGMP.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)

if(NOT ${GMP_SOURCE} STREQUAL "")
if(NOT "${GMP_SOURCE}" STREQUAL "")
set(GMP_LOCATION ${GMP_SOURCE})
set(GMP_URL_HASH_COMMAND)
else()
Expand Down
28 changes: 14 additions & 14 deletions src/abycore/cmake/Modules/FetchENCRYPTO_utils.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
cmake_minimum_required(VERSION 3.13)

set(ENCRYPTO_utils_SOURCE
CACHE PATH
"Path to ENCRYPTO_utils source."
)
set(ENCRYPTO_utils_URL
https://github.com/oliver-schick/ENCRYPTO_utils/archive/23639b335f64532abdf64cdd131473599799ad62.zip
CACHE STRING
"URL of ENCRYPTO_utils project."
)
set(ENCRYPTO_utils_URL_HASH
SHA256=37a4de5c943cd98592e1af2f8cd3b6f76337ccdbdba80dbf777a2f7c951dae15
CACHE STRING
"Hash of ENCRYPTO_utils archive."
)
set(ENCRYPTO_utils_SOURCE CACHE PATH "Path to ENCRYPTO_utils source.")
set(ENCRYPTO_utils_REPOSITORY
https://github.com/oliver-schick/ENCRYPTO_utils.git
CACHE STRING "Git repository of ENCRYPTO_utils project.")
set(ENCRYPTO_utils_TAG master CACHE STRING "Git tag of downloaded ENCRYPTO_utils project.")
#Specific commit hash. Please regularly update to maintain compatibility with ABY.
set(ENCRYPTO_utils_URL
https://github.com/oliver-schick/ENCRYPTO_utils/archive/0380d7f82bc871ab9b1c593265e92482a070d8cf.zip
CACHE STRING "URL of ENCRYPTO_utils project.")
#sha256sum of downloaded file. To get it on linux simply type following command line:
#$ wget -O out [URL] && sha256sum out
set(ENCRYPTO_utils_URL_HASH SHA256=e50fe0667a313a3209492bac20516750b4fa6b8bb19fd94f84043ac1fbbdbd68 CACHE STRING "Hash of ENCRYPTO_utils archive.")
option(DOWNLOAD_ENCRYPTO_utils "Set this option to download a specific commit of ENCRYPTO_utils." OFF)
mark_as_advanced(ENCRYPTO_utils_REPOSITORY ENCRYPTO_utils_TAG ENCRYPTO_utils_URL ENCRYPTO_utils_URL_HASH DOWNLOAD_ENCRYPTO_utils)

include(FetchHelper)
fetch_helper(ENCRYPTO_utils)
35 changes: 23 additions & 12 deletions src/abycore/cmake/Modules/FetchHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,40 @@ macro(fetch_helper content_name)
else()
set(${content_name}_DOWNLOAD_DIR_COMMAND "")
endif()
if(NOT ${${content_name}_SOURCE} STREQUAL "")
set(${content_name}_URL_COMMAND URL ${${content_name}_SOURCE})
set(${content_name}_URL_HASH_COMMAND "")
if(NOT "${${content_name}_SOURCE}" STREQUAL "")
set(${content_name}_DOWNLOAD_COMMAND1 URL ${${content_name}_SOURCE})
set(${content_name}_DOWNLOAD_COMMAND2 "")
elseif(DOWNLOAD_${content_name} OR "${${content_name}_REPOSITORY}" STREQUAL "")
set(${content_name}_DOWNLOAD_COMMAND1 URL ${${content_name}_URL})
set(${content_name}_DOWNLOAD_COMMAND2 URL_HASH ${${content_name}_URL_HASH})
else()
set(${content_name}_URL_COMMAND URL ${${content_name}_URL})
set(${content_name}_URL_HASH_COMMAND URL_HASH ${${content_name}_URL_HASH})
set(${content_name}_DOWNLOAD_COMMAND1 GIT_REPOSITORY ${${content_name}_REPOSITORY})
set(${content_name}_DOWNLOAD_COMMAND2 GIT_TAG ${${content_name}_TAG})
endif()
include(FetchContent)
FetchContent_Declare(${content_name}
${${content_name}_URL_COMMAND}
${${content_name}_URL_HASH_COMMAND}
${${content_name}_DOWNLOAD_COMMAND1}
${${content_name}_DOWNLOAD_COMMAND2}
${${content_name}_DOWNLOAD_DIR_COMMAND}
)
FetchContent_GetProperties(${content_name})
if(NOT ${LOWER_CASE_${content_name}}_POPULATED)
FetchContent_Populate(${content_name})
if(${ARGV1})
if(NOT "${ARGV1}" STREQUAL "")
message(STATUS "Applying patches to ${content_name}...")
include("Patch${content_name}")
endif()
add_subdirectory(
${${LOWER_CASE_${content_name}}_SOURCE_DIR}
${${LOWER_CASE_${content_name}}_BINARY_DIR}
)
if(NOT "${ARGV2}" STREQUAL "")
add_subdirectory(
${${LOWER_CASE_${content_name}}_SOURCE_DIR}
${${LOWER_CASE_${content_name}}_BINARY_DIR}
EXCLUDE_FROM_ALL
)
else()
add_subdirectory(
${${LOWER_CASE_${content_name}}_SOURCE_DIR}
${${LOWER_CASE_${content_name}}_BINARY_DIR}
)
endif()
endif()
endmacro()
26 changes: 13 additions & 13 deletions src/abycore/cmake/Modules/FetchOTExtension.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
cmake_minimum_required(VERSION 3.13)

set(OTExtension_SOURCE
CACHE PATH
"Path to OTExtension source."
)
set(OTExtension_SOURCE CACHE PATH "Path to OTExtension source.")
set(OTExtension_REPOSITORY
https://github.com/oliver-schick/OTExtension.git
CACHE STRING "Git repository of OTExtension project.")
set(OTExtension_TAG master CACHE STRING "Git tag of downloaded OTExtension project.")
#Specific commit hash. Please regularly update to maintain compatibility with ABY.
set(OTExtension_URL
https://github.com/oliver-schick/OTExtension/archive/a923a0b72faf5203a99233e696c163af1e5c17d2.zip
CACHE STRING
"URL of OTExtension project."
)
set(OTExtension_URL_HASH
SHA256=58e8ff999ee2fddd985072c8f629b402609f8dbb6ec5c41b3c2f0e1c452a88a8
CACHE STRING
"Hash of OTExtension archive."
)
https://github.com/oliver-schick/OTExtension/archive/5948eb026ac94f88c55b2d198ccc89234a79858f.zip
CACHE STRING "URL of OTExtension project.")
#sha256sum of downloaded file. To get it on linux simply type following command line:
#$ wget -O out [URL] && sha256sum out
set(OTExtension_URL_HASH SHA256=c64bc174706ddd7def18dcd8974b55ee8036d371a7d85fea0a48bfe290ca0b23 CACHE STRING "Hash of OTExtension archive.")
option(DOWNLOAD_OTExtension "Set this option to download a specific commit of OTExtension." OFF)
mark_as_advanced(OTExtension_REPOSITORY OTExtension_TAG OTExtension_URL OTExtension_URL_HASH DOWNLOAD_OTExtension)

include(FetchHelper)
fetch_helper(OTExtension)

0 comments on commit afd317e

Please sign in to comment.