[czmq] Add new port (#4979)

* [czmq] Add new port

* [czmq] Modernize

* [czmq] Update to 2019-05-17

* [czmq] Update to 2019-05-29

* [czmq] Fix OpenSSL not found issue on x64-windows

* [czmq] Update portfile.cmake

* [czmq] Update to 2019-06-10

* [czmq] Clean

* [czmq] Add Homepage

* [czmq] Use vcpkg_check_features

* [czmq] Disable parallel configuration

* Fix typo when using feature options
This commit is contained in:
myd7349 2019-07-03 06:23:53 +08:00 committed by Griffin Downs
parent 24b1618b29
commit fb4cc37262
9 changed files with 289 additions and 0 deletions

27
ports/czmq/CONTROL Normal file
View File

@ -0,0 +1,27 @@
Source: czmq
Version: 2019-06-10
Build-Depends: zeromq
Description: High-level C binding for ZeroMQ
Homepage: https://github.com/zeromq/czmq
Feature: tool
Description: Build and install czmq tools (zmakecert)
Feature: draft
Description: Build and install draft APIs
Feature: curl
Description: Build with libcurl
Build-Depends: curl
Feature: lz4
Description: Build with lz4
Build-Depends: lz4
Feature: httpd
Description: Build with HTTP server support (libmicrohttpd)
Build-Depends: libmicrohttpd
Feature: uuid
Description: Build with libuuid
Build-Depends: libuuid (!windows&!uwp&!osx)

View File

@ -0,0 +1,51 @@
find_path(
LIBCURL_INCLUDE_DIRS
NAMES curl/curl.h
)
find_library(
LIBCURL_LIBRARY_DEBUG
NAMES libcurl-d_imp libcurl-d curl-d curl
)
find_library(
LIBCURL_LIBRARY_RELEASE
NAMES libcurl_imp libcurl curl
)
include(SelectLibraryConfigurations)
select_library_configurations(LIBCURL)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LIBCURL
REQUIRED_VARS LIBCURL_LIBRARIES LIBCURL_INCLUDE_DIRS
)
# CURL dependencies
# https://github.com/Microsoft/vcpkg/issues/4312
# https://github.com/microsoft/vcpkg/commit/ee325d14276e7bd7961e94e58293b02d6e9e92da
# https://github.com/microsoft/vcpkg/pull/6698
if (LIBCURL_FOUND)
find_package(OpenSSL QUIET)
find_package(ZLIB QUIET)
if (OPENSSL_FOUND)
list(APPEND LIBCURL_LIBRARIES
OpenSSL::SSL
OpenSSL::Crypto
)
endif ()
if (ZLIB_FOUND)
list(APPEND LIBCURL_LIBRARIES
ZLIB::ZLIB
)
endif ()
if (WIN32)
list(APPEND LIBCURL_LIBRARIES
Crypt32
)
endif ()
endif ()

View File

@ -0,0 +1,28 @@
find_path(LIBMICROHTTPD_INCLUDE_DIRS NAMES microhttpd.h)
get_filename_component(_prefix_path ${LIBMICROHTTPD_INCLUDE_DIRS} PATH)
find_library(
LIBMICROHTTPD_LIBRARY_DEBUG
NAMES libmicrohttpd microhttpd
PATHS ${_prefix_path}/debug/lib
NO_DEFAULT_PATH
)
find_library(
LIBMICROHTTPD_LIBRARY_RELEASE
NAMES libmicrohttpd microhttpd
PATHS ${_prefix_path}/lib
NO_DEFAULT_PATH
)
unset(_prefix_path)
include(SelectLibraryConfigurations)
select_library_configurations(LIBMICROHTTPD)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LIBMICROHTTPD
REQUIRED_VARS LIBMICROHTTPD_LIBRARIES LIBMICROHTTPD_INCLUDE_DIRS
)

View File

@ -0,0 +1,10 @@
find_package(ZeroMQ CONFIG REQUIRED)
set(LIBZMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR})
set(LIBZMQ_LIBRARIES libzmq libzmq-static)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LIBZMQ
REQUIRED_VARS LIBZMQ_LIBRARIES LIBZMQ_INCLUDE_DIRS
)

13
ports/czmq/Findlz4.cmake Normal file
View File

@ -0,0 +1,13 @@
find_path(LZ4_INCLUDE_DIRS NAMES lz4.h)
find_library(LZ4_LIBRARY_DEBUG NAMES lz4d)
find_library(LZ4_LIBRARY_RELEASE NAMES lz4)
include(SelectLibraryConfigurations)
select_library_configurations(LZ4)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LZ4
REQUIRED_VARS LZ4_LIBRARIES LZ4_INCLUDE_DIRS
)

31
ports/czmq/Finduuid.cmake Normal file
View File

@ -0,0 +1,31 @@
find_path(
UUID_INCLUDE_DIRS
NAMES uuid/uuid.h
)
get_filename_component(_prefix_path ${UUID_INCLUDE_DIRS} PATH)
find_library(
UUID_LIBRARY_DEBUG
NAMES uuid
PATHS ${_prefix_path}/debug/lib
NO_DEFAULT_PATH
)
find_library(
UUID_LIBRARY_RELEASE
NAMES uuid
PATHS ${_prefix_path}/lib
NO_DEFAULT_PATH
)
unset(_prefix_path)
include(SelectLibraryConfigurations)
select_library_configurations(UUID)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
UUID
REQUIRED_VARS UUID_LIBRARIES UUID_INCLUDE_DIRS
)

View File

@ -0,0 +1,19 @@
diff --git a/builds/cmake/Config.cmake.in b/builds/cmake/Config.cmake.in
index 9c15f36a..e1475cd6 100644
--- a/builds/cmake/Config.cmake.in
+++ b/builds/cmake/Config.cmake.in
@@ -1,4 +1,14 @@
@PACKAGE_INIT@
+include(CMakeFindDependencyMacro)
+
+find_dependency(ZeroMQ)
+
+if (@CZMQ_WITH_LIBCURL@ AND @LIBCURL_FOUND@)
+ find_dependency(OpenSSL)
+ find_dependency(ZLIB)
+endif ()
+
+
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components("@PROJECT_NAME@")

101
ports/czmq/portfile.cmake Normal file
View File

@ -0,0 +1,101 @@
include(vcpkg_common_functions)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO zeromq/czmq
REF 7e29cf95305551daad197e32423d9cff5f9b6893
SHA512 7d79494c904f5276c9d1e4a193a63882dc622a6db8998b9719de4aec8b223b3a8b3c92ea02be81f39afc12c1a883b310fd3662ea27ed736b0b9c7092b4843a18
HEAD_REF master
PATCHES
fix-dependencies.patch
)
foreach(_cmake_module
Findlibcurl.cmake
Findlibmicrohttpd.cmake
Findlibzmq.cmake
Findlz4.cmake
Finduuid.cmake
)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/${_cmake_module}
${SOURCE_PATH}/${_cmake_module}
COPYONLY
)
endforeach()
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
vcpkg_check_features(
draft ENABLE_DRAFTS
tool BUILD_TOOLS
curl CZMQ_WITH_LIBCURL
httpd CZMQ_WITH_LIBMICROHTTPD
lz4 CZMQ_WITH_LZ4
uuid CZMQ_WITH_UUID
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DCZMQ_BUILD_SHARED=${BUILD_SHARED}
-DCZMQ_BUILD_STATIC=${BUILD_STATIC}
-DBUILD_TESTING=OFF
${FEATURE_OPTIONS}
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
if(EXISTS ${CURRENT_PACKAGES_DIR}/CMake)
vcpkg_fixup_cmake_targets(CONFIG_PATH CMake)
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/share/cmake/${PORT})
vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/${PORT})
endif()
file(COPY
${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake
DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}
)
if(CMAKE_HOST_WIN32)
set(EXECUTABLE_SUFFIX ".exe")
else()
set(EXECUTABLE_SUFFIX "")
endif()
if (BUILD_TOOLS)
file(COPY ${CURRENT_PACKAGES_DIR}/bin/zmakecert${EXECUTABLE_SUFFIX}
DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT})
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
endif()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/czmq_library.h
"if defined CZMQ_STATIC"
"if 1 //if defined CZMQ_STATIC"
)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/bin
${CURRENT_PACKAGES_DIR}/debug/bin)
else()
file(REMOVE
${CURRENT_PACKAGES_DIR}/debug/bin/zmakecert${EXECUTABLE_SUFFIX}
${CURRENT_PACKAGES_DIR}/bin/zmakecert${EXECUTABLE_SUFFIX})
endif()
# Handle copyright
configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
# CMake integration test
vcpkg_test_cmake(PACKAGE_NAME ${PORT})

View File

@ -0,0 +1,9 @@
_find_package(${ARGS})
if(TARGET czmq AND NOT TARGET czmq-static)
add_library(czmq-static INTERFACE IMPORTED)
set_target_properties(czmq-static PROPERTIES INTERFACE_LINK_LIBRARIES czmq)
elseif(TARGET czmq-static AND NOT TARGET czmq)
add_library(czmq INTERFACE IMPORTED)
set_target_properties(czmq PROPERTIES INTERFACE_LINK_LIBRARIES czmq-static)
endif()