[zkpp] Add new port (#7001)

* [zkpp] Add new port

* [zkpp] Change name of underlying library

* [zookeeper] Fix interface include directories

* [zkpp] Sanity

* Fix patch

* Correctly expose include directories

* Bump version

* Explicitly fail on Windows

Co-authored-by: Raed Romanov <raid_r@mail.ru>
This commit is contained in:
Samuel Marks 2020-03-11 06:20:42 +11:00 committed by GitHub
parent 7ffa425e1d
commit d1b89575bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 225 additions and 51 deletions

111
ports/zkpp/CMakeLists.txt Normal file
View File

@ -0,0 +1,111 @@
#
# This file is based on https://github.com/tgockel/zookeeper-cpp/blob/a8d5f905e01893256299d5532b1836f64c89b5b9/CMakeLists.txt
# Which is licensed under Apache License 2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
cmake_minimum_required(VERSION 3.5)
file(READ src/zk/config.hpp CONFIG_HPP_STR)
string(REGEX REPLACE ".*# *define +ZKPP_VERSION_MAJOR +([0-9]+).*" "\\1" ZKPP_VERSION_MAJOR "${CONFIG_HPP_STR}")
string(REGEX REPLACE ".*# *define +ZKPP_VERSION_MINOR +([0-9]+).*" "\\1" ZKPP_VERSION_MINOR "${CONFIG_HPP_STR}")
string(REGEX REPLACE ".*# *define +ZKPP_VERSION_PATCH +([0-9]+).*" "\\1" ZKPP_VERSION_PATCH "${CONFIG_HPP_STR}")
set(ZKPP_VERSION "${ZKPP_VERSION_MAJOR}.${ZKPP_VERSION_MINOR}.${ZKPP_VERSION_PATCH}")
project(zookeeper-cpp
LANGUAGES CXX
VERSION "${ZKPP_VERSION}"
)
set(PROJECT_SO_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
message(STATUS "Software Version: ${ZKPP_VERSION}")
################################################################################
# CMake #
################################################################################
cmake_policy(VERSION 3.5)
cmake_policy(SET CMP0037 OLD) # allow generation of "test" target
set(CMAKE_REQUIRED_QUIET YES) # tell check_include_file_cxx to keep quiet
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
include(BuildFunctions)
include(CheckIncludeFileCXX)
include(ConfigurationSetting)
include(ListSplit)
include(GNUInstallDirs)
################################################################################
# Build Configuration #
################################################################################
find_package(Threads REQUIRED)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
message(STATUS "No build type selected, default to ${CMAKE_BUILD_TYPE}")
endif()
set(VALID_BUILD_TYPES Debug Release)
if(NOT ${CMAKE_BUILD_TYPE} IN_LIST VALID_BUILD_TYPES)
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}\nValid build types are: ${VALID_BUILD_TYPES}")
endif()
message(STATUS "Configuration: ${CMAKE_BUILD_TYPE}")
message(STATUS "Features:")
build_option(NAME CODE_COVERAGE
DOC "Enable code coverage (turns on the test-coverage target)"
DEFAULT OFF
CONFIGS_ON Debug
)
configuration_setting(NAME BUFFER
DOC "Type to use for zk::buffer"
DEFAULT STD_VECTOR
OPTIONS
STD_VECTOR
CUSTOM
)
configuration_setting(NAME FUTURE
DOC "Type to use for zk::future<T> and zk::promise<T>"
DEFAULT STD
OPTIONS
STD
STD_EXPERIMENTAL
CUSTOM
)
set(CXX_STANDARD c++17
CACHE STRING "The language standard to target for C++."
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=${CXX_STANDARD}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DZKPP_DEBUG=1")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
################################################################################
# External Libraries #
################################################################################
find_package(zookeeper REQUIRED)
build_module(NAME zkpp
PATH src/zk
NO_RECURSE
)
target_include_directories(zkpp PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
target_link_libraries(zkpp PRIVATE zookeeper::zookeeper)
install(TARGETS zkpp
EXPORT zkpp
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(FILES ${zkpp_LIBRARY_HEADERS} DESTINATION include/zk/)
install(EXPORT zkpp DESTINATION share/zkpp/ FILE zkppConfig.cmake)

5
ports/zkpp/CONTROL Normal file
View File

@ -0,0 +1,5 @@
Source: zkpp
Version: 0.2.3
Homepage: https://github.com/tgockel/zookeeper-cpp
Description: A ZooKeeper client for C++.
Build-Depends: zookeeper

28
ports/zkpp/portfile.cmake Normal file
View File

@ -0,0 +1,28 @@
vcpkg_fail_port_install(ON_TARGET "Windows")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO tgockel/zookeeper-cpp
REF v0.2.3
SHA512 086f31d4ca53f5a585fd8640caf9f2f21c90cf46d9cfe6c0e8e5b8c620e73265bb8aebec62ea4328f3f098a9b3000280582569966c0d3401627ab8c3edc31ca8
HEAD_REF master
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(GLOB_RECURSE test_files LIST_DIRECTORIES false "${SOURCE_PATH}/src/zk/*_tests.cpp")
if (NOT "${test_files}" STREQUAL "")
file(REMOVE ${test_files})
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
vcpkg_fixup_cmake_targets()
vcpkg_copy_pdbs()

View File

@ -1,5 +1,5 @@
Source: zookeeper
Version: 3.5.5
Version: 3.5.5-1
Description: ZooKeeper C bindings
Default-Features: sync

View File

@ -1,50 +1,74 @@
diff --git a/zookeeper-client/zookeeper-client-c/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/CMakeLists.txt
index 24a5a1b..1b0ce4a 100644
--- a/zookeeper-client/zookeeper-client-c/CMakeLists.txt
+++ b/zookeeper-client/zookeeper-client-c/CMakeLists.txt
@@ -153,7 +153,7 @@ configure_file(cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
# hashtable library
set(hashtable_sources src/hashtable/hashtable_itr.c src/hashtable/hashtable.c)
add_library(hashtable STATIC ${hashtable_sources})
-target_include_directories(hashtable PUBLIC include)
+target_include_directories(hashtable PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(hashtable PUBLIC $<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:FreeBSD>>:m>)
# zookeeper library
@@ -176,7 +176,10 @@ if(WIN32)
endif()
add_library(zookeeper STATIC ${zookeeper_sources})
-target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated)
+target_include_directories(zookeeper PUBLIC
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/generated>)
+
target_link_libraries(zookeeper PUBLIC
hashtable
$<$<PLATFORM_ID:Linux>:rt> # clock_gettime
@@ -247,3 +250,23 @@ if(WANT_CPPUNIT)
"ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.."
"CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover*.jar")
endif()
+
+
+target_compile_definitions(zookeeper PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+target_compile_definitions(cli PRIVATE _CRT_SECURE_NO_WARNINGS)
+
+file(GLOB ZOOKEEPER_HEADERS include/*.h)
+
+install(FILES ${ZOOKEEPER_HEADERS} generated/zookeeper.jute.h DESTINATION include/zookeeper)
+
+install(TARGETS zookeeper hashtable
+ EXPORT zookeeperConfig
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
+install(EXPORT zookeeperConfig
+ FILE zookeeperConfig.cmake
+ NAMESPACE zookeeper::
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/zookeeper"
+)
\ No newline at end of file
diff --git a/zookeeper-client/zookeeper-client-c/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/CMakeLists.txt
index 24a5a1b..40fa67e 100644
--- a/zookeeper-client/zookeeper-client-c/CMakeLists.txt
+++ b/zookeeper-client/zookeeper-client-c/CMakeLists.txt
@@ -147,13 +147,15 @@ endforeach()
include(CheckStructHasMember)
check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" ZOO_IPV6_ENABLED)
+include(GNUInstallDirs)
+
# configure
configure_file(cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
# hashtable library
set(hashtable_sources src/hashtable/hashtable_itr.c src/hashtable/hashtable.c)
add_library(hashtable STATIC ${hashtable_sources})
-target_include_directories(hashtable PUBLIC include)
+target_include_directories(hashtable PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(hashtable PUBLIC $<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:FreeBSD>>:m>)
# zookeeper library
@@ -176,11 +178,16 @@ if(WIN32)
endif()
add_library(zookeeper STATIC ${zookeeper_sources})
-target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated)
+target_include_directories(zookeeper PUBLIC
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/generated>)
+
target_link_libraries(zookeeper PUBLIC
- hashtable
$<$<PLATFORM_ID:Linux>:rt> # clock_gettime
- $<$<PLATFORM_ID:Windows>:ws2_32>) # Winsock 2.0
+ $<$<PLATFORM_ID:Windows>:ws2_32> # Winsock 2.0
+ PRIVATE hashtable)
if(WANT_SYNCAPI AND NOT WIN32)
find_package(Threads REQUIRED)
@@ -189,7 +196,7 @@ endif()
# cli executable
add_executable(cli src/cli.c)
-target_link_libraries(cli zookeeper)
+target_link_libraries(cli PRIVATE zookeeper)
# load_gen executable
if(WANT_SYNCAPI AND NOT WIN32)
@@ -247,3 +254,23 @@ if(WANT_CPPUNIT)
"ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.."
"CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover*.jar")
endif()
+
+
+target_compile_definitions(zookeeper PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+target_compile_definitions(cli PRIVATE _CRT_SECURE_NO_WARNINGS)
+
+file(GLOB ZOOKEEPER_HEADERS include/*.h)
+
+install(FILES ${ZOOKEEPER_HEADERS} generated/zookeeper.jute.h DESTINATION include/zookeeper)
+
+install(TARGETS zookeeper hashtable
+ EXPORT zookeeperConfig
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
+install(EXPORT zookeeperConfig
+ FILE zookeeperConfig.cmake
+ NAMESPACE zookeeper::
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/zookeeper"
+)

View File

@ -1896,3 +1896,9 @@ z3:x64-uwp=fail
zeromq:arm64-windows=fail
zeromq:arm-uwp=fail
zeromq:x64-uwp=fail
zkpp:x86-windows=fail
zkpp:x64-windows=fail
zkpp:x64-windows-static=fail
zkpp:arm64-windows=fail
zkpp:x64-uwp=fail
zkpp:arm-uwp=fail