move sodium cmake target about so that it is detected earlier

pull/1306/head
Jeff Becker 4 years ago
parent 8fc52fcbbe
commit c6bd0afe96
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -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)

@ -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
)

@ -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()

@ -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)

@ -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)

Loading…
Cancel
Save