[usockets,uwebsockets] Update uwebsockets to 20.71.0, install and test CMake config, Cleanup (#42538)

This commit is contained in:
Kai Pastor 2024-12-12 21:17:15 +01:00 committed by GitHub
parent 1c1bbf2544
commit 6c42b86e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 237 additions and 94 deletions

View File

@ -1,68 +1,58 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.30)
project(uSockets C CXX)
option(INSTALL_HEADERS "Install header files" ON)
option(WITH_OPENSSL "Enables OpenSSL 1.1+ support")
if (CMAKE_USE_OPENSSL)
# Upstream compiles all sources at once
option(CMAKE_UNITY_BUILD "Combine source for compilation." ON)
file(GLOB C_SOURCES src/*.c src/eventing/*.c)
add_library(uSockets ${C_SOURCES})
set_target_properties(uSockets PROPERTIES EXPORT_NAME usockets)
target_include_directories(uSockets
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
"$<INSTALL_INTERFACE:include>"
)
if(WITH_OPENSSL)
file(GLOB CRYPTO_SOURCES src/crypto/*.c*)
target_sources(uSockets PRIVATE ${CRYPTO_SOURCES})
target_compile_features(uSockets PRIVATE cxx_std_17)
# https://github.com/uNetworking/uSockets/blob/0ebdde0601cc82349fc11a7c4bbb6dc5c9f28f42/Makefile#L55
find_package(OpenSSL REQUIRED)
set(USE_OPENSSL "-DUSE_OPENSSL -DLIBUS_USE_OPENSSL")
#set(OPENSSL_LIB "OpenSSL::SSL OpenSSL::Crypto")
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
target_link_libraries(uSockets PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(uSockets PRIVATE -DLIBUS_USE_OPENSSL)
else()
set(NOT_USE_OPENSSL "-DLIBUS_NO_SSL")
target_compile_definitions(uSockets PRIVATE -DLIBUS_NO_SSL)
endif()
find_package(libuv CONFIG REQUIRED)
if (TARGET libuv::uv)
set(LIBUV_LIBRARY libuv::uv)
else()
set(LIBUV_LIBRARY libuv::uv_a)
if(WIN32)
# https://github.com/uNetworking/uSockets/blob/8606de6414a102c55bef8e8ef3391932d7e8df6a/src/libusockets.h#L339-L348
find_package(libuv CONFIG REQUIRED)
target_link_libraries(uSockets PRIVATE $<IF:$<TARGET_EXISTS:libuv::uv_a>,libuv::uv_a,libuv::uv>)
target_compile_definitions(uSockets PRIVATE -DLIBUS_USE_LIBUV)
# https://github.com/uNetworking/uSockets/blob/8606de6414a102c55bef8e8ef3391932d7e8df6a/src/libusockets.h#L35
target_link_libraries(uSockets PRIVATE ws2_32)
endif()
file(GLOB SOURCES src/*.c src/eventing/*.c)
set(USOCKETS_EXT_INCLUDE_DIR )
set(USOCKETS_EXT_LIBS )
if (CMAKE_USE_OPENSSL)
# It requires C++17 or later, see https://github.com/uNetworking/uSockets/blob/0ebdde0601cc82349fc11a7c4bbb6dc5c9f28f42/Makefile#L55
set(CMAKE_CXX_STANDARD 17)
find_package(OpenSSL REQUIRED)
file(GLOB SSL_SOURCES src/crypto/*.c*)
list(APPEND SOURCES ${SSL_SOURCES})
list(APPEND USOCKETS_EXT_LIBS OpenSSL::SSL OpenSSL::Crypto)
endif()
if (CMAKE_USE_EVENT)
file(GLOB SSL_SOURCES src/eventing/*.c)
list(APPEND SOURCES ${SSL_SOURCES})
list(APPEND USOCKETS_EXT_INCLUDE_DIR src/internal/eventing)
endif()
if (CMAKE_USE_NETWORK)
list(APPEND USOCKETS_EXT_INCLUDE_DIR src/internal/networking)
list(APPEND USOCKETS_EXT_LIBS ws2_32)
endif()
add_library(uSockets ${SOURCES})
if (${LIBUS_USE_LIBUV})
target_compile_definitions(uSockets PRIVATE -DLIBUS_USE_LIBUV)
endif()
target_compile_definitions(uSockets PRIVATE ${NOT_USE_OPENSSL} ${USE_OPENSSL})
target_include_directories(uSockets PUBLIC ${OPENSSL_INCLUDE_DIR} ${USOCKETS_EXT_INCLUDE_DIR} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src")
target_link_libraries(uSockets PUBLIC ${OPENSSL_LIBRARIES} ${LIBUV_LIBRARY} ${USOCKETS_EXT_LIBS})
install(TARGETS uSockets
EXPORT unofficial-usockets-targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
if(INSTALL_HEADERS)
file(GLOB HEADERS src/*.h)
install(FILES ${HEADERS} DESTINATION include)
file(GLOB HEADERS src/interfaces/*.h)
install(FILES ${HEADERS} DESTINATION include/interfaces)
endif()
install(EXPORT unofficial-usockets-targets
NAMESPACE unofficial::usockets::
DESTINATION share/unofficial-usockets
)
configure_file("unofficial-usockets-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-usockets-config.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-usockets-config.cmake"
DESTINATION share/unofficial-usockets
)
install(FILES src/libusockets.h DESTINATION include)

View File

@ -1,13 +1,6 @@
vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) #Upstream only support static compilation: https://github.com/uNetworking/uSockets/commit/b950efd6b10f06dd3ecb5b692e5d415f48474647
if(NOT VCPKG_TARGET_IS_LINUX)
set(USE_LIBUV ON)
endif()
if ("network" IN_LIST FEATURES AND NOT VCPKG_TARGET_IS_WINDOWS)
message(FATAL_ERROR "Feature 'network' is only supported on Windows")
endif()
# Upstream only support static compilation,
# https://github.com/uNetworking/uSockets/commit/b950efd6b10f06dd3ecb5b692e5d415f48474647
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
@ -16,27 +9,23 @@ vcpkg_from_github(
SHA512 726b1665209d0006d6621352c12019bbab22bed75450c5ef1509b409d3c19c059caf94775439d3b910676fa2a4a790d490c3e25e5b8141423d88823642be7ac7
HEAD_REF master
)
file(COPY "${CURRENT_PORT_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CURRENT_PORT_DIR}/unofficial-usockets-config.cmake" DESTINATION "${SOURCE_PATH}")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
ssl CMAKE_USE_OPENSSL
event CMAKE_USE_EVENT
network CMAKE_USE_NETWORK
ssl WITH_OPENSSL
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
"-DLIBUS_USE_LIBUV=${USE_LIBUV}"
OPTIONS_DEBUG
-DINSTALL_HEADERS=OFF
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-usockets)
vcpkg_copy_pdbs()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
vcpkg_copy_pdbs()

View File

@ -0,0 +1,8 @@
include(CMakeFindDependencyMacro)
if(WIN32)
find_dependency(libuv CONFIG)
endif()
if("@WITH_OPENSSL@")
find_dependency(OpenSSL)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-usockets-targets.cmake")

View File

@ -1,29 +1,27 @@
{
"name": "usockets",
"version": "0.8.8",
"port-version": 1,
"port-version": 2,
"description": "Miniscule cross-platform eventing, networking & crypto for async applications",
"homepage": "https://github.com/uNetworking/uSockets",
"license": "Apache-2.0",
"dependencies": [
"libuv",
{
"name": "libuv",
"platform": "windows"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"event": {
"description": "Build usockets with epoll support"
},
"network": {
"description": "Build usockets with winsock support",
"dependencies": [
"winsock2"
]
},
"ssl": {
"description": "Build usockets with openssl support",
"description": "Enable SSL support",
"dependencies": [
"openssl"
]

View File

@ -3,11 +3,17 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO uNetworking/uWebSockets
REF "v${VERSION}"
SHA512 49c0193e6b6dad5533f489b0a0247b5f5e3fa27b96e499699a42dcca2406a159b0158d11c4527bc7dd8da8b56427ff15eb08c28a660527ee76c1579366d3dd57
SHA512 542de9c2e007c37b6c25e58d58de6a4aa9b6f19b4b681856e40094d49e5c5c132798e79dc384b4609a8f876491779874e2778c76d7b00c16e53f44f4726739b5
HEAD_REF master
)
file(COPY "${SOURCE_PATH}/src" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(RENAME "${CURRENT_PACKAGES_DIR}/include/src" "${CURRENT_PACKAGES_DIR}/include/uwebsockets")
set(UWS_NO_ZLIB 1)
if("zlib" IN_LIST FEATURES)
set(UWS_NO_ZLIB 0)
endif()
configure_file("${CURRENT_PORT_DIR}/unofficial-uwebsockets-config.cmake" "${CURRENT_PACKAGES_DIR}/share/unofficial-uwebsockets/unofficial-uwebsockets-config.cmake" @ONLY)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

View File

@ -0,0 +1,19 @@
include(CMakeFindDependencyMacro)
find_dependency(unofficial-usockets CONFIG)
if(NOT "@UWS_NO_ZLIB@")
find_dependency(ZLIB)
endif()
if(NOT TARGET unofficial::uwebsockets::uwebsockets)
add_library(unofficial::uwebsockets::uwebsockets INTERFACE IMPORTED)
target_compile_features(unofficial::uwebsockets::uwebsockets INTERFACE cxx_std_17)
get_filename_component(_uws_include_dir "../../include" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
target_include_directories(unofficial::uwebsockets::uwebsockets INTERFACE "${_uws_include_dir}")
unset(_uws_include_dir)
target_link_libraries(unofficial::uwebsockets::uwebsockets INTERFACE $<LINK_ONLY:unofficial::usockets::usockets>)
if("@UWS_NO_ZLIB@")
target_compile_definitions(unofficial::uwebsockets::uwebsockets INTERFACE UWS_NO_ZLIB)
else()
target_link_libraries(unofficial::uwebsockets::uwebsockets INTERFACE ZLIB::ZLIB)
endif()
endif()

View File

@ -1,11 +1,29 @@
{
"name": "uwebsockets",
"version-semver": "20.70.0",
"version-semver": "20.71.0",
"description": "Simple, secure & standards compliant web I/O for the most demanding of applications",
"homepage": "https://github.com/uWebSockets/uWebSockets",
"license": "Apache-2.0",
"dependencies": [
"usockets",
"zlib"
]
"usockets"
],
"features": {
"ssl": {
"description": "Enable SSL support",
"dependencies": [
{
"name": "usockets",
"features": [
"ssl"
]
}
]
},
"zlib": {
"description": "Enable ZLIB support",
"dependencies": [
"zlib"
]
}
}
}

View File

@ -0,0 +1,40 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e8ac94c..027ee22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,14 +29,7 @@ set(VCPKG_BUILD_TYPE ${CMAKE_BUILD_TYPE})
message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message("VCPKG_BUILD_TYPE: ${VCPKG_BUILD_TYPE}")
-find_path(UWEBSOCKETS_INCLUDE_DIRS "uwebsockets/App.h")
-message("µWebsockets include dir: ${UWEBSOCKETS_INCLUDE_DIRS}")
-if(WIN32)
- find_library(LIBUSOCKETS_STATIC uSockets.lib)
-else(WIN32)
- find_library(LIBUSOCKETS_STATIC libuSockets.a)
-endif(WIN32)
-message(${LIBUSOCKETS_STATIC})
+find_package(unofficial-uwebsockets CONFIG REQUIRED)
find_path(MDNS_INCLUDE_DIRS "mdns.h")
message("mdns include dir: ${MDNS_INCLUDE_DIRS}")
@@ -44,8 +37,6 @@ message("mdns include dir: ${MDNS_INCLUDE_DIRS}")
find_package(mdns REQUIRED)
find_package(nlohmann_json 3.11.2 REQUIRED)
find_package(nlohmann_json_schema_validator REQUIRED)
-find_package(libuv REQUIRED NO_MODULE)
-find_package(ZLIB REQUIRED)
if(WT_WITH_SSL)
find_package(OpenSSL REQUIRED)
@@ -68,5 +59,10 @@ target_include_directories(webthing-cpp INTERFACE
$<BUILD_INTERFACE:"${CMAKE_CURRENT_SOURCE_DIR}/include}">
$<INSTALL_INTERFACE:include>
)
+target_link_libraries(webthing-cpp INTERFACE
+ nlohmann_json_schema_validator::validator
+ nlohmann_json::nlohmann_json
+ unofficial::uwebsockets::uwebsockets
+)
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_PREFIX}/include")

View File

@ -6,6 +6,8 @@ vcpkg_from_github(
REF "v${VERSION}"
SHA512 a4df3424721542ea4a7951ffc643905d31d906bcf87bed613b422ba8c0babb406f842459ba6c6df73c332c70c6fdd639413dc42272fd3b27fdf96b2cee528d36
HEAD_REF master
PATCHES
dependencies.diff
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS

View File

@ -1,6 +1,7 @@
{
"name": "webthing-cpp",
"version": "1.0.5",
"port-version": 1,
"description": "Webthing-CPP is a modern CPP/C++17 implementation of the WebThings API.",
"homepage": "https://github.com/bw-hro/webthing-cpp",
"license": "MIT",
@ -19,7 +20,7 @@
"description": "Support HTTPS via uwebsockets",
"dependencies": [
{
"name": "usockets",
"name": "uwebsockets",
"features": [
"ssl"
]

View File

@ -0,0 +1,4 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/project")
vcpkg_cmake_build()

View File

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.30)
project(uwebsockets-test CXX)
find_package(unofficial-uwebsockets CONFIG REQUIRED)
add_executable(main main.cxx)
target_link_libraries(main PRIVATE
$<TARGET_NAME:unofficial::uwebsockets::uwebsockets>
)

View File

@ -0,0 +1,10 @@
#include <string>
#include <uwebsockets/App.h>
int main()
{
uWS::App().get("/hello", [](auto *res, auto *req) {
res->end("Hello World!");
});
return 0;
}

View File

@ -0,0 +1,34 @@
{
"name": "vcpkg-ci-uwebsockets",
"version-string": "ci",
"description": "Port to test features of uwebsockets within CI",
"homepage": "https://github.com/microsoft/vcpkg",
"license": "MIT",
"dependencies": [
{
"name": "uwebsockets",
"default-features": false
},
{
"name": "vcpkg-cmake",
"host": true
}
],
"default-features": [
"all"
],
"features": {
"all": {
"description": "Test all features",
"dependencies": [
{
"name": "uwebsockets",
"features": [
"ssl",
"zlib"
]
}
]
}
}
}

View File

@ -9274,7 +9274,7 @@
},
"usockets": {
"baseline": "0.8.8",
"port-version": 1
"port-version": 2
},
"usrsctp": {
"baseline": "0.9.5.0",
@ -9317,7 +9317,7 @@
"port-version": 0
},
"uwebsockets": {
"baseline": "20.70.0",
"baseline": "20.71.0",
"port-version": 0
},
"v-hacd": {
@ -9626,7 +9626,7 @@
},
"webthing-cpp": {
"baseline": "1.0.5",
"port-version": 0
"port-version": 1
},
"webview2": {
"baseline": "1.0.2277.86",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "28a78040653744fdea484a20a0cfee8b14f14312",
"version": "0.8.8",
"port-version": 2
},
{
"git-tree": "166a701806a36e58117b39db8786c566ed8fd44b",
"version": "0.8.8",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "378799c0e7e9f97bfd3b80aa9776a798f287f34d",
"version-semver": "20.71.0",
"port-version": 0
},
{
"git-tree": "be8eaa143a359edd215ab039b7f7422e6bc392f0",
"version-semver": "20.70.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "dceca0241738ad48d83db43f70d0884d83ab6e3d",
"version": "1.0.5",
"port-version": 1
},
{
"git-tree": "478564ecb6732d9d2f6dde40ca8ff122f6dabe00",
"version": "1.0.5",