[zeromq] Add sodium support and fix static build (#4214)

* [zeromq] Add new feature

* [zeromq] Fix static build
This commit is contained in:
myd7349 2019-03-08 08:43:12 +08:00 committed by Victor Romero
parent a675e048df
commit adc005f877
2 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,7 @@
Source: zeromq
Version: 2019-01-30
Description: The ZeroMQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products
Feature: sodium
Description: Using libsodium for CURVE security
Build-Depends: libsodium

View File

@ -14,6 +14,12 @@ string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} \"-I${SOURCE_PATH}/builds/msvc\"")
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} \"-I${SOURCE_PATH}/builds/msvc\"")
if("sodium" IN_LIST FEATURES)
set(WITH_LIBSODIUM ON)
else()
set(WITH_LIBSODIUM OFF)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
@ -22,6 +28,7 @@ vcpkg_configure_cmake(
-DPOLLER=select
-DBUILD_STATIC=${BUILD_STATIC}
-DBUILD_SHARED=${BUILD_SHARED}
-DWITH_LIBSODIUM=${WITH_LIBSODIUM}
-DWITH_PERF_TOOL=OFF
OPTIONS_DEBUG
"-DCMAKE_PDB_OUTPUT_DIRECTORY=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
@ -38,6 +45,13 @@ if(EXISTS ${CURRENT_PACKAGES_DIR}/share/cmake/ZeroMQ)
vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/ZeroMQ)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/zmq.h
"defined ZMQ_STATIC"
"1 //defined ZMQ_STATIC"
)
endif()
file(READ ${CURRENT_PACKAGES_DIR}/share/zeromq/ZeroMQConfig.cmake _contents)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
string(REPLACE "get_target_property(ZeroMQ_STATIC_LIBRARY libzmq-static LOCATION)" "add_library(libzmq-static INTERFACE IMPORTED)\nset_target_properties(libzmq-static PROPERTIES INTERFACE_LINK_LIBRARIES libzmq)" _contents "${_contents}")