diff --git a/ports/libjuice/CONTROL b/ports/libjuice/CONTROL new file mode 100644 index 0000000000..5901d8d74f --- /dev/null +++ b/ports/libjuice/CONTROL @@ -0,0 +1,8 @@ +Source: libjuice +Version: 0.5.2 +Homepage: https://github.com/paullouisageneau/libjuice +Description: The library is a simplified implementation of the Interactive Connectivity Establishment (ICE) protocol in C for POSIX platforms (including Linux and Apple macOS) and Microsoft Windows. + +Feature: nettle +Build-Depends: nettle +Description: Use nettle for HMAC computation instead of the Builtin diff --git a/ports/libjuice/fix-for-vcpkg.patch b/ports/libjuice/fix-for-vcpkg.patch new file mode 100644 index 0000000000..6bbfd837f0 --- /dev/null +++ b/ports/libjuice/fix-for-vcpkg.patch @@ -0,0 +1,68 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index be72a2a..8a631e8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,6 +41,9 @@ set(LIBJUICE_SOURCES + set(LIBJUICE_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/include/juice/juice.h + ) ++set(LIBJUICE_PRIVATE_HEADERS ++ ${CMAKE_CURRENT_SOURCE_DIR}/src/socket.h ++) + + set(TESTS_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/test/main.c +@@ -54,10 +57,10 @@ set(TESTS_SOURCES + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + +-add_library(juice SHARED ${LIBJUICE_SOURCES}) ++add_library(juice ${LIBJUICE_SOURCES}) + set_target_properties(juice PROPERTIES VERSION ${PROJECT_VERSION}) + +-target_include_directories(juice PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) ++target_include_directories(juice PUBLIC $ $) + target_include_directories(juice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/juice) + target_include_directories(juice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + target_link_libraries(juice PUBLIC Threads::Threads) +@@ -77,10 +80,14 @@ endif() + + if (USE_NETTLE) + find_package(Nettle REQUIRED) ++ find_path(NETTLE_INCLUDE_PATH "nettle/hmac.h" REQUIRED) ++ target_include_directories(juice PRIVATE ${NETTLE_INCLUDE_PATH}) ++ target_include_directories(juice-static PRIVATE ${NETTLE_INCLUDE_PATH}) ++ + target_compile_definitions(juice PRIVATE USE_NETTLE=1) +- target_link_libraries(juice PRIVATE Nettle::Nettle) ++ target_link_libraries(juice PRIVATE nettle) + target_compile_definitions(juice-static PRIVATE USE_NETTLE=1) +- target_link_libraries(juice-static PRIVATE Nettle::Nettle) ++ target_link_libraries(juice-static PRIVATE nettle) + else() + target_compile_definitions(juice PRIVATE USE_NETTLE=0) + target_compile_definitions(juice-static PRIVATE USE_NETTLE=0) +@@ -100,8 +107,13 @@ endif() + add_library(LibJuice::LibJuice ALIAS juice) + add_library(LibJuice::LibJuiceStatic ALIAS juice-static) + +-install(TARGETS juice LIBRARY DESTINATION lib) ++install(TARGETS juice EXPORT libjuice-config ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++) + install(FILES ${LIBJUICE_HEADERS} DESTINATION include/juice) ++install(FILES ${LIBJUICE_PRIVATE_HEADERS} DESTINATION include/juice/src) + + if(NOT MSVC) + target_compile_options(juice PRIVATE -Wall -Wextra) +@@ -128,3 +140,8 @@ if(NOT NO_TESTS) + target_link_libraries(juice-tests juice) + endif() + ++install( ++ EXPORT libjuice-config ++ NAMESPACE LibJuice:: ++ DESTINATION share/cmake/libjuice ++) diff --git a/ports/libjuice/portfile.cmake b/ports/libjuice/portfile.cmake new file mode 100644 index 0000000000..68770243fe --- /dev/null +++ b/ports/libjuice/portfile.cmake @@ -0,0 +1,31 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO paullouisageneau/libjuice + REF 92fc9e7a9d8cd19a5c5d59cbc0a11cc9f684483b + SHA512 80e9898c51bc98a60ca317030bc5394fda412c2bc822adc656f88bfa60b42501d4945a8692771afb8241ec7994fbe48c3e8360f919a0859cfb47288fd3292dd4 + HEAD_REF master + PATCHES + fix-for-vcpkg.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + nettle USE_NETTLE +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + ${FEATURE_OPTIONS} + -DNO_TESTS=ON +) + +vcpkg_install_cmake() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/libjuice) +vcpkg_fixup_pkgconfig() + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)