aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/usockets
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/usockets
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/usockets')
-rw-r--r--vcpkg/ports/usockets/CMakeLists.txt60
-rw-r--r--vcpkg/ports/usockets/portfile.cmake31
-rw-r--r--vcpkg/ports/usockets/unofficial-usockets-config.cmake8
-rw-r--r--vcpkg/ports/usockets/vcpkg.json30
4 files changed, 129 insertions, 0 deletions
diff --git a/vcpkg/ports/usockets/CMakeLists.txt b/vcpkg/ports/usockets/CMakeLists.txt
new file mode 100644
index 0000000..0fe9d5d
--- /dev/null
+++ b/vcpkg/ports/usockets/CMakeLists.txt
@@ -0,0 +1,60 @@
+cmake_minimum_required(VERSION 3.30)
+project(uSockets C CXX)
+
+option(WITH_OPENSSL "Enables OpenSSL 1.1+ support")
+
+# 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)
+ target_link_libraries(uSockets PRIVATE OpenSSL::SSL OpenSSL::Crypto)
+ target_compile_definitions(uSockets PRIVATE -DLIBUS_USE_OPENSSL)
+else()
+ target_compile_definitions(uSockets PRIVATE -DLIBUS_NO_SSL)
+endif()
+
+if(WIN32 OR ANDROID)
+ # 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)
+
+ if(WIN32)
+ # https://github.com/uNetworking/uSockets/blob/8606de6414a102c55bef8e8ef3391932d7e8df6a/src/libusockets.h#L35
+ target_link_libraries(uSockets PRIVATE ws2_32)
+ endif()
+endif()
+
+
+install(TARGETS uSockets
+ EXPORT unofficial-usockets-targets
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
+
+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)
diff --git a/vcpkg/ports/usockets/portfile.cmake b/vcpkg/ports/usockets/portfile.cmake
new file mode 100644
index 0000000..175e942
--- /dev/null
+++ b/vcpkg/ports/usockets/portfile.cmake
@@ -0,0 +1,31 @@
+# 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
+ REPO uNetworking/uSockets
+ REF "v${VERSION}"
+ 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 WITH_OPENSSL
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ ${FEATURE_OPTIONS}
+)
+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")
diff --git a/vcpkg/ports/usockets/unofficial-usockets-config.cmake b/vcpkg/ports/usockets/unofficial-usockets-config.cmake
new file mode 100644
index 0000000..2737221
--- /dev/null
+++ b/vcpkg/ports/usockets/unofficial-usockets-config.cmake
@@ -0,0 +1,8 @@
+include(CMakeFindDependencyMacro)
+if(WIN32 OR ANDROID)
+ find_dependency(libuv CONFIG)
+endif()
+if("@WITH_OPENSSL@")
+ find_dependency(OpenSSL)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-usockets-targets.cmake")
diff --git a/vcpkg/ports/usockets/vcpkg.json b/vcpkg/ports/usockets/vcpkg.json
new file mode 100644
index 0000000..255f582
--- /dev/null
+++ b/vcpkg/ports/usockets/vcpkg.json
@@ -0,0 +1,30 @@
+{
+ "name": "usockets",
+ "version": "0.8.8",
+ "port-version": 3,
+ "description": "Miniscule cross-platform eventing, networking & crypto for async applications",
+ "homepage": "https://github.com/uNetworking/uSockets",
+ "license": "Apache-2.0",
+ "dependencies": [
+ {
+ "name": "libuv",
+ "platform": "windows | android"
+ },
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ],
+ "features": {
+ "ssl": {
+ "description": "Enable SSL support",
+ "dependencies": [
+ "openssl"
+ ]
+ }
+ }
+}