aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/zookeeper
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/zookeeper')
-rw-r--r--vcpkg/ports/zookeeper/cmake.patch56
-rw-r--r--vcpkg/ports/zookeeper/portfile.cmake79
-rw-r--r--vcpkg/ports/zookeeper/unofficial-zookeeperConfig.cmake8
-rw-r--r--vcpkg/ports/zookeeper/usage4
-rw-r--r--vcpkg/ports/zookeeper/vcpkg.json28
-rw-r--r--vcpkg/ports/zookeeper/win32.patch28
6 files changed, 203 insertions, 0 deletions
diff --git a/vcpkg/ports/zookeeper/cmake.patch b/vcpkg/ports/zookeeper/cmake.patch
new file mode 100644
index 0000000..ff8d08b
--- /dev/null
+++ b/vcpkg/ports/zookeeper/cmake.patch
@@ -0,0 +1,56 @@
+diff --git a/zookeeper-client/zookeeper-client-c/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/CMakeLists.txt
+index ccba3ee..14384c0 100644
+--- a/zookeeper-client/zookeeper-client-c/CMakeLists.txt
++++ b/zookeeper-client/zookeeper-client-c/CMakeLists.txt
+@@ -169,7 +169,11 @@ 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
++ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
++ $<INSTALL_INTERFACE:include>
++)
++set_target_properties(hashtable PROPERTIES OUTPUT_NAME zookeeper_hashtable)
+ target_link_libraries(hashtable PUBLIC $<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:FreeBSD>>:m>)
+
+ # zookeeper library
+@@ -196,7 +200,12 @@ 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
++ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
++ $<INSTALL_INTERFACE: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
+@@ -291,3 +300,24 @@ if(WANT_CPPUNIT)
+ "ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.."
+ "CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover*.jar")
+ endif()
++
++if(WIN32)
++ 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)
++endif()
++
++file(GLOB ZOOKEEPER_HEADERS include/*.h)
++install(FILES ${ZOOKEEPER_HEADERS} generated/zookeeper.jute.h DESTINATION include/zookeeper)
++
++install(TARGETS zookeeper hashtable
++ EXPORT unofficial-zookeeperTargets
++ RUNTIME DESTINATION bin
++ ARCHIVE DESTINATION lib
++ LIBRARY DESTINATION lib
++)
++install(EXPORT unofficial-zookeeperTargets
++ NAMESPACE unofficial::zookeeper::
++ DESTINATION share/unofficial-zookeeper
++)
++configure_file("${CMAKE_CURRENT_SOURCE_DIR}/unofficial-zookeeperConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-zookeeperConfig.cmake" @ONLY)
++install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-zookeeperConfig.cmake" DESTINATION share/unofficial-zookeeper)
diff --git a/vcpkg/ports/zookeeper/portfile.cmake b/vcpkg/ports/zookeeper/portfile.cmake
new file mode 100644
index 0000000..0b0f935
--- /dev/null
+++ b/vcpkg/ports/zookeeper/portfile.cmake
@@ -0,0 +1,79 @@
+vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+string(REGEX REPLACE "^([0-9]+[.][0-9]+[.][0-9]+)[.]([0-9]+)\$" "\\1-\\2" VERSION "${VERSION}")
+
+vcpkg_download_distfile(
+ zookeeper_src_archive
+ URLS "https://dlcdn.apache.org/zookeeper/stable/apache-zookeeper-${VERSION}.tar.gz"
+ FILENAME "apache-zookeeper-${VERSION}.tar.gz"
+ SHA512 78d909c92b3709cc2112d1b8df9ef006f78a81ee0aa1b6b6400b8fea771ebaafc03cde497c6080e3fd924b75facb28420c4970885914e5dc9cd47cd761e96dd4
+)
+vcpkg_extract_source_archive(
+ SOURCE_PATH
+ ARCHIVE "${zookeeper_src_archive}"
+ PATCHES
+ cmake.patch
+ win32.patch
+)
+file(COPY "${CURRENT_PORT_DIR}/unofficial-zookeeperConfig.cmake" DESTINATION "${SOURCE_PATH}/zookeeper-client/zookeeper-client-c")
+
+# We must run the jute generator which is made from Java sources.
+# We fetch it as JAR from the latest matching binary release of zookeeper.
+vcpkg_download_distfile(
+ zookeeper_bin_archive
+ URLS "https://dlcdn.apache.org/zookeeper/stable/apache-zookeeper-${VERSION}-bin.tar.gz"
+ FILENAME "apache-zookeeper-${VERSION}-bin.tar.gz"
+ SHA512 4d85d6f7644d5f36d9c4d65e78bd662ab35ebe1380d762c24c12b98af029027eee453437c9245dbdf2b9beb77cd6b690b69e26f91cf9d11b0a183a979c73fa43
+)
+vcpkg_extract_source_archive(
+ zookeeper_jute_path
+ ARCHIVE "${zookeeper_bin_archive}"
+)
+string(APPEND zookeeper_jute_path "/lib/zookeeper-jute-${VERSION}.jar")
+
+block(SCOPE_FOR VARIABLES)
+ # Do not warn about FindJava.cmake accessing WIN32
+ set(Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "TRACE")
+ set(WIN32 "${CMAKE_HOST_WIN32}")
+ find_package(Java COMPONENTS Runtime REQUIRED)
+
+ # cf. zookeeper-jute/pom.xml > "generate-C-Jute"
+ file(MAKE_DIRECTORY "${SOURCE_PATH}/zookeeper-client/zookeeper-client-c/generated")
+ vcpkg_execute_required_process(
+ COMMAND "${Java_JAVA_EXECUTABLE}"
+ -classpath "${zookeeper_jute_path}"
+ org.apache.jute.compiler.generated.Rcc
+ -l c
+ "${SOURCE_PATH}/zookeeper-jute/src/main/resources/zookeeper.jute"
+ WORKING_DIRECTORY "${SOURCE_PATH}/zookeeper-client/zookeeper-client-c/generated"
+ LOGNAME "generate-C-Jute"
+ )
+endblock()
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ openssl WITH_OPENSSL
+ openssl VCPKG_LOCK_FIND_PACKAGE_OpenSSL
+ sync WANT_SYNCAPI
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}/zookeeper-client/zookeeper-client-c"
+ OPTIONS
+ -DTHREADS_PREFER_PTHREAD_FLAG=ON
+ -DWANT_CPPUNIT=OFF
+ -DWITH_CYRUS_SASL=OFF
+ ${FEATURE_OPTIONS}
+ MAYBE_UNUSED_VARIABLES
+ THREADS_PREFER_PTHREAD_FLAG
+ VCPKG_LOCK_FIND_PACKAGE_OpenSSL
+)
+
+vcpkg_cmake_install()
+vcpkg_copy_pdbs()
+vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-zookeeper)
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+
+file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/zookeeper-client/zookeeper-client-c/LICENSE")
diff --git a/vcpkg/ports/zookeeper/unofficial-zookeeperConfig.cmake b/vcpkg/ports/zookeeper/unofficial-zookeeperConfig.cmake
new file mode 100644
index 0000000..19e565e
--- /dev/null
+++ b/vcpkg/ports/zookeeper/unofficial-zookeeperConfig.cmake
@@ -0,0 +1,8 @@
+include(CMakeFindDependencyMacro)
+if("@WANT_SYNCAPI@" AND NOT WIN32)
+ find_dependency(Threads)
+endif()
+if("@WITH_OPENSSL@")
+ find_dependency(OpenSSL)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-zookeeperTargets.cmake")
diff --git a/vcpkg/ports/zookeeper/usage b/vcpkg/ports/zookeeper/usage
new file mode 100644
index 0000000..833ce6d
--- /dev/null
+++ b/vcpkg/ports/zookeeper/usage
@@ -0,0 +1,4 @@
+zookeeper provides CMake targets:
+
+ find_package(unofficial-zookeeper CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE unofficial::zookeeper::zookeeper)
diff --git a/vcpkg/ports/zookeeper/vcpkg.json b/vcpkg/ports/zookeeper/vcpkg.json
new file mode 100644
index 0000000..4f5ac26
--- /dev/null
+++ b/vcpkg/ports/zookeeper/vcpkg.json
@@ -0,0 +1,28 @@
+{
+ "name": "zookeeper",
+ "version": "3.8.4",
+ "description": "ZooKeeper C bindings",
+ "homepage": "https://github.com/apache/zookeeper",
+ "license": "BSD-3-Clause",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ],
+ "features": {
+ "openssl": {
+ "description": "Enable OpenSSL support",
+ "dependencies": [
+ "openssl"
+ ]
+ },
+ "sync": {
+ "description": "ZooKeeper with the sync API"
+ }
+ }
+}
diff --git a/vcpkg/ports/zookeeper/win32.patch b/vcpkg/ports/zookeeper/win32.patch
new file mode 100644
index 0000000..141d25e
--- /dev/null
+++ b/vcpkg/ports/zookeeper/win32.patch
@@ -0,0 +1,28 @@
+diff --git a/zookeeper-client/zookeeper-client-c/src/zk_log.c b/zookeeper-client/zookeeper-client-c/src/zk_log.c
+index 79ebd61..2f9d018 100644
+--- a/zookeeper-client/zookeeper-client-c/src/zk_log.c
++++ b/zookeeper-client/zookeeper-client-c/src/zk_log.c
+@@ -108,7 +108,11 @@ static const char* time_now(char* now_str){
+ gettimeofday(&tv,0);
+
+ now = tv.tv_sec;
++#ifdef WIN32
++ localtime_s(&lt, &now);
++#else
+ localtime_r(&now, &lt);
++#endif
+
+ // clone the format used by logback ISO8601DateFormat
+ // specifically: "yyyy-MM-dd HH:mm:ss,SSS"
+diff --git a/zookeeper-client/zookeeper-client-c/src/zookeeper.c b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+index 74b0471..e9cd44b 100644
+--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
++++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+@@ -100,6 +100,7 @@
+ #define EAI_ADDRFAMILY WSAEINVAL /* is this still needed? */
+ #define EHOSTDOWN EPIPE
+ #define ESTALE ENODEV
++#define strtok_r strtok_s
+ #endif
+
+ #define IF_DEBUG(x) if(logLevel==ZOO_LOG_LEVEL_DEBUG) {x;}