Skip to content

Commit

Permalink
[zyre] Add new port (#7189)
Browse files Browse the repository at this point in the history
  • Loading branch information
myd7349 authored and dan-shaw committed Jul 12, 2019
1 parent 1e542bc commit c477e87
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ports/zyre/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Source: zyre
Version: 2019-07-07
Build-Depends: czmq
Description: An open-source framework for proximity-based peer-to-peer applications
Homepage: https://github.com/zeromq/zyre
9 changes: 9 additions & 0 deletions ports/zyre/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(ZeroMQ)
find_dependency(czmq)

include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components("@PROJECT_NAME@")
10 changes: 10 additions & 0 deletions ports/zyre/Findczmq.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
find_path(CZMQ_INCLUDE_DIRS NAMES czmq.h)

find_package(czmq CONFIG REQUIRED)
set(CZMQ_LIBRARIES czmq czmq-static)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
CZMQ
REQUIRED_VARS CZMQ_INCLUDE_DIRS CZMQ_LIBRARIES
)
10 changes: 10 additions & 0 deletions ports/zyre/Findlibzmq.cmake
Original file line number Diff line number Diff line change
@@ -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
)
87 changes: 87 additions & 0 deletions ports/zyre/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
include(vcpkg_common_functions)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO zeromq/zyre
REF 2648b7eb806a2494d6eb4177f0941232d83c5294
SHA512 8940e82ccdc427734711d63dc01c81fe86c4ca6b7e97a69df979f4d48a4711df1ccaee6a3b6aa394f9ef91d719cb95851c4eb87dfa9ed6426e2577b95e0fb464
HEAD_REF master
)

configure_file(
${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in
${SOURCE_PATH}/builds/cmake/Config.cmake.in
COPYONLY
)

foreach(_cmake_module Findczmq.cmake Findlibzmq.cmake)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/${_cmake_module}
${SOURCE_PATH}/${_cmake_module}
COPYONLY
)
endforeach()

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ZYRE_BUILD_SHARED)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ZYRE_BUILD_STATIC)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DZYRE_BUILD_SHARED=${ZYRE_BUILD_SHARED}
-DZYRE_BUILD_STATIC=${ZYRE_BUILD_STATIC}
-DENABLE_DRAFTS=OFF
)

vcpkg_install_cmake()

vcpkg_copy_pdbs()

if(EXISTS ${CURRENT_PACKAGES_DIR}/CMake)
vcpkg_fixup_cmake_targets(CONFIG_PATH CMake)
elseif(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(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(EXECUTABLE_SUFFIX ".exe")
else()
set(EXECUTABLE_SUFFIX "")
endif()

file(COPY ${CURRENT_PACKAGES_DIR}/bin/zpinger${EXECUTABLE_SUFFIX}
DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT})
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})

if(ZYRE_BUILD_SHARED)
file(REMOVE
${CURRENT_PACKAGES_DIR}/debug/bin/zpinger${EXECUTABLE_SUFFIX}
${CURRENT_PACKAGES_DIR}/bin/zpinger${EXECUTABLE_SUFFIX})
else()
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/bin
${CURRENT_PACKAGES_DIR}/debug/bin)
endif()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

if(ZYRE_BUILD_STATIC)
vcpkg_replace_string(
${CURRENT_PACKAGES_DIR}/include/zyre_library.h
"if defined ZYRE_STATIC"
"if 1 //if defined ZYRE_STATIC"
)
endif()

# Handle copyright
configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)

# CMake integration test
vcpkg_test_cmake(PACKAGE_NAME ${PORT})
9 changes: 9 additions & 0 deletions ports/zyre/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_find_package(${ARGS})

if(TARGET zyre AND NOT TARGET zyre-static)
add_library(zyre-static INTERFACE IMPORTED)
set_target_properties(zyre-static PROPERTIES INTERFACE_LINK_LIBRARIES zyre)
elseif(TARGET zyre-static AND NOT TARGET zyre)
add_library(zyre INTERFACE IMPORTED)
set_target_properties(zyre PROPERTIES INTERFACE_LINK_LIBRARIES zyre-static)
endif()

0 comments on commit c477e87

Please sign in to comment.