mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-06 08:41:15 +01:00
CMake: use libsodium if available, else use tweet_nacl
This commit is contained in:
parent
5d98e602c9
commit
55ca9c5654
@ -9,14 +9,17 @@ if(APPLE)
|
|||||||
option(ZMQ_BUILD_FRAMEWORK "Build as OS X framework" ON)
|
option(ZMQ_BUILD_FRAMEWORK "Build as OS X framework" ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}")
|
||||||
option(WITH_TWEETNACL "Build with tweetnacl" OFF)
|
find_package(Sodium)
|
||||||
else()
|
|
||||||
option(WITH_TWEETNACL "Build with tweetnacl" ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WITH_TWEETNACL)
|
set(USE_TWEETNACL OFF)
|
||||||
add_definitions(-DHAVE_TWEETNACL -DHAVE_LIBSODIUM)
|
|
||||||
|
if(SODIUM_FOUND)
|
||||||
|
add_definitions(-DHAVE_LIBSODIUM)
|
||||||
|
include_directories(${SODIUM_INCLUDE_DIRS})
|
||||||
|
else()
|
||||||
|
set(USE_TWEETNACL ON)
|
||||||
|
add_definitions(-DHAVE_TWEETNACL)
|
||||||
include_directories(
|
include_directories(
|
||||||
tweetnacl/contrib/randombytes
|
tweetnacl/contrib/randombytes
|
||||||
tweetnacl/src
|
tweetnacl/src
|
||||||
@ -25,16 +28,12 @@ if(WITH_TWEETNACL)
|
|||||||
set(TWEETNACL_SOURCES
|
set(TWEETNACL_SOURCES
|
||||||
tweetnacl/src/tweetnacl.c
|
tweetnacl/src/tweetnacl.c
|
||||||
)
|
)
|
||||||
if(WIN32)
|
|
||||||
else()
|
if(NOT WIN32)
|
||||||
list(APPEND TWEETNACL_SOURCES tweetnacl/contrib/randombytes/devurandom.c)
|
list(APPEND TWEETNACL_SOURCES tweetnacl/contrib/randombytes/devurandom.c)
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
find_library(SODIUM_FOUND sodium)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(POLLER "" CACHE STRING "Choose polling system. valid values are
|
set(POLLER "" CACHE STRING "Choose polling system. valid values are
|
||||||
kqueue, epoll, devpoll, poll or select [default=autodetect]")
|
kqueue, epoll, devpoll, poll or select [default=autodetect]")
|
||||||
|
|
||||||
@ -502,9 +501,11 @@ foreach(source ${cxx-sources})
|
|||||||
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/src/${source})
|
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/src/${source})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(source ${TWEETNACL_SOURCES})
|
if(USE_TWEETNACL)
|
||||||
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
foreach(source ${TWEETNACL_SOURCES})
|
||||||
endforeach()
|
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(source ${rc-sources})
|
foreach(source ${rc-sources})
|
||||||
list(APPEND sources ${CMAKE_CURRENT_BINARY_DIR}/${source})
|
list(APPEND sources ${CMAKE_CURRENT_BINARY_DIR}/${source})
|
||||||
@ -602,7 +603,7 @@ else()
|
|||||||
PUBLIC_HEADER "${public_headers}"
|
PUBLIC_HEADER "${public_headers}"
|
||||||
VERSION ${ZMQ_VERSION}
|
VERSION ${ZMQ_VERSION}
|
||||||
SOVERSION "${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.0"
|
SOVERSION "${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.0"
|
||||||
OUTPUT_NAME "libzmq")
|
OUTPUT_NAME "libzmq")
|
||||||
if(ZMQ_BUILD_FRAMEWORK)
|
if(ZMQ_BUILD_FRAMEWORK)
|
||||||
set_target_properties(libzmq PROPERTIES
|
set_target_properties(libzmq PROPERTIES
|
||||||
FRAMEWORK TRUE
|
FRAMEWORK TRUE
|
||||||
@ -623,7 +624,11 @@ else()
|
|||||||
OUTPUT_NAME "libzmq-static")
|
OUTPUT_NAME "libzmq-static")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(libzmq ${SODIUM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(libzmq ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
|
if(SODIUM_FOUND)
|
||||||
|
target_link_libraries(libzmq ${SODIUM_LIBRARIES})
|
||||||
|
endif()
|
||||||
if(HAVE_WS2_32)
|
if(HAVE_WS2_32)
|
||||||
target_link_libraries(libzmq ws2_32)
|
target_link_libraries(libzmq ws2_32)
|
||||||
elseif(HAVE_WS2)
|
elseif(HAVE_WS2)
|
||||||
|
40
FindSodium.cmake
Normal file
40
FindSodium.cmake
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
################################################################################
|
||||||
|
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
||||||
|
# Please refer to the README for information about making permanent changes. #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
if (NOT MSVC)
|
||||||
|
include(FindPkgConfig)
|
||||||
|
pkg_check_modules(PC_SODIUM "libsodium")
|
||||||
|
if (NOT PC_SODIUM_FOUND)
|
||||||
|
pkg_check_modules(PC_SODIUM "sodium")
|
||||||
|
endif (NOT PC_SODIUM_FOUND)
|
||||||
|
if (PC_SODIUM_FOUND)
|
||||||
|
set(SODIUM_INCLUDE_HINTS ${PC_SODIUM_INCLUDE_DIRS} ${PC_SODIUM_INCLUDE_DIRS}/*)
|
||||||
|
set(SODIUM_LIBRARY_HINTS ${PC_SODIUM_LIBRARY_DIRS} ${PC_SODIUM_LIBRARY_DIRS}/*)
|
||||||
|
endif()
|
||||||
|
endif (NOT MSVC)
|
||||||
|
|
||||||
|
# some libraries install the headers is a subdirectory of the include dir
|
||||||
|
# returned by pkg-config, so use a wildcard match to improve chances of finding
|
||||||
|
# headers and libraries.
|
||||||
|
find_path(
|
||||||
|
SODIUM_INCLUDE_DIRS
|
||||||
|
NAMES sodium.h
|
||||||
|
HINTS ${SODIUM_INCLUDE_HINTS}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(
|
||||||
|
SODIUM_LIBRARIES
|
||||||
|
NAMES libsodium sodium
|
||||||
|
HINTS ${SODIUM_LIBRARY_HINTS}
|
||||||
|
)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(SODIUM DEFAULT_MSG SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
||||||
|
mark_as_advanced(SODIUM_FOUND SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
||||||
|
# Please refer to the README for information about making permanent changes. #
|
||||||
|
################################################################################
|
@ -50,7 +50,7 @@ set(tests
|
|||||||
test_pub_invert_matching
|
test_pub_invert_matching
|
||||||
test_thread_safe
|
test_thread_safe
|
||||||
test_client_server
|
test_client_server
|
||||||
test_sockopt_hwm
|
test_sockopt_hwm
|
||||||
test_heartbeats
|
test_heartbeats
|
||||||
test_poller
|
test_poller
|
||||||
)
|
)
|
||||||
@ -83,6 +83,7 @@ foreach(test ${tests})
|
|||||||
else()
|
else()
|
||||||
add_test(NAME ${test} COMMAND ${test})
|
add_test(NAME ${test} COMMAND ${test})
|
||||||
endif()
|
endif()
|
||||||
|
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
|
Loading…
Reference in New Issue
Block a user