From c6bd0afe96b3a906ecbbb38d46322070d32276d0 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 26 Jun 2020 13:45:08 -0400 Subject: [PATCH] move sodium cmake target about so that it is detected earlier --- CMakeLists.txt | 14 ++++++++++++++ cmake/DownloadLibSodium.cmake | 6 +++--- cmake/FindSodium.cmake | 2 +- cmake/unix.cmake | 24 ------------------------ crypto/CMakeLists.txt | 18 +----------------- 5 files changed, 19 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1136c0655..e6254452d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,6 +123,20 @@ if(NOT WIN32) endif() +option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF) +# Allow -DDOWNLOAD_SODIUM=FORCE to download without even checking for a local libsodium +if((NOT BUILD_STATIC_DEPS) AND (NOT DOWNLOAD_SODIUM STREQUAL "FORCE")) + find_package(Sodium 1.0.18) +endif() + +if(SODIUM_FOUND OR BUILD_STATIC_DEPS) +elseif(DOWNLOAD_SODIUM) + message(STATUS "Sodium >= 1.0.18 not found, but DOWNLOAD_SODIUM specified, so downloading it") + include(DownloadLibSodium) +else() + message(FATAL_ERROR "Could not find libsodium >= 1.0.18; either install it on your system or use -DDOWNLOAD_SODIUM=ON to download and build an internal copy") +endif() + option(FORCE_LOKIMQ_SUBMODULE "force using lokimq submodule" OFF) if(NOT FORCE_LOKIMQ_SUBMODULE) find_package(LokiMQ 1.2) diff --git a/cmake/DownloadLibSodium.cmake b/cmake/DownloadLibSodium.cmake index b558155a0..f01d6c642 100644 --- a/cmake/DownloadLibSodium.cmake +++ b/cmake/DownloadLibSodium.cmake @@ -43,9 +43,9 @@ ExternalProject_Add(libsodium_external BUILD_BYPRODUCTS ${LIBSODIUM_PREFIX}/lib/libsodium.a ${LIBSODIUM_PREFIX}/include ) -add_library(sodium_vendor STATIC IMPORTED GLOBAL) -add_dependencies(sodium_vendor libsodium_external) -set_target_properties(sodium_vendor PROPERTIES +add_library(sodium STATIC IMPORTED GLOBAL) +add_dependencies(sodium libsodium_external) +set_target_properties(sodium PROPERTIES IMPORTED_LOCATION ${LIBSODIUM_PREFIX}/lib/libsodium.a INTERFACE_INCLUDE_DIRECTORIES ${LIBSODIUM_PREFIX}/include ) diff --git a/cmake/FindSodium.cmake b/cmake/FindSodium.cmake index 3d5a2d99c..3b82a1264 100644 --- a/cmake/FindSodium.cmake +++ b/cmake/FindSodium.cmake @@ -218,7 +218,7 @@ if (sodium_INCLUDE_DIR) file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT) string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" "\\1" sodium_VERSION "${_VERSION_HEADER_CONTENT}") - set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE) + set(sodium_VERSION "${sodium_VERSION}") endif() endif() diff --git a/cmake/unix.cmake b/cmake/unix.cmake index 7b2ae71a4..f090f9b5c 100644 --- a/cmake/unix.cmake +++ b/cmake/unix.cmake @@ -14,30 +14,6 @@ if(WITH_JEMALLOC) message(STATUS "using jemalloc") endif() -add_library(curl INTERFACE) - -option(DOWNLOAD_CURL "download and statically compile in CURL" OFF) -# Allow -DDOWNLOAD_CURL=FORCE to download without even checking for a local libcurl -if(NOT DOWNLOAD_CURL STREQUAL "FORCE") - include(FindCURL) -endif() - -if(CURL_FOUND) - message(STATUS "using system curl") - if(TARGET CURL::libcurl) # cmake 3.12+ - target_link_libraries(curl INTERFACE CURL::libcurl) - else() - target_link_libraries(curl INTERFACE ${CURL_LIBRARIES}) - target_include_directories(curl INTERFACE ${CURL_INCLUDE_DIRS}) - endif() -elseif(DOWNLOAD_CURL) - message(STATUS "libcurl not found, but DOWNLOAD_CURL specified, so downloading it") - include(DownloadLibCurl) - target_link_libraries(curl INTERFACE curl_vendor) -else() - message(FATAL_ERROR "Could not find libcurl; either install it on your system or use -DDOWNLOAD_CURL=ON to download and build an internal copy") -endif() - add_definitions(-DUNIX) add_definitions(-DPOSIX) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index b28426d2d..e74060996 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -66,21 +66,5 @@ if (WARNINGS_AS_ERRORS) target_compile_options(lokinet-cryptography PUBLIC -Wall -Wextra -Werror) endif() - -option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF) - -# Allow -DDOWNLOAD_SODIUM=FORCE to download without even checking for a local libsodium -if((NOT BUILD_STATIC_DEPS) AND (NOT DOWNLOAD_SODIUM STREQUAL "FORCE")) - find_package(Sodium 1.0.18) -endif() - -if(sodium_FOUND OR BUILD_STATIC_DEPS) - target_link_libraries(lokinet-cryptography PUBLIC sodium) -elseif(DOWNLOAD_SODIUM) - message(STATUS "Sodium >= 1.0.18 not found, but DOWNLOAD_SODIUM specified, so downloading it") - include(DownloadLibSodium) - target_link_libraries(lokinet-cryptography PUBLIC sodium_vendor) -else() - message(FATAL_ERROR "Could not find libsodium >= 1.0.18; either install it on your system or use -DDOWNLOAD_SODIUM=ON to download and build an internal copy") -endif() +target_link_libraries(lokinet-cryptography PUBLIC sodium)