vcpkg/ports/glaze/001-fix-asio.patch

65 lines
2.7 KiB
Diff

diff --git a/cmake/install-config.cmake.in b/cmake/install-config.cmake.in
index dbd6977f..b2ea2c64 100644
--- a/cmake/install-config.cmake.in
+++ b/cmake/install-config.cmake.in
@@ -10,6 +10,26 @@ if(_glaze_EETF_FORMAT)
endif()
unset(_glaze_EETF_FORMAT)
+set(_glaze_ENABLE_NETWORKING "@glaze_ENABLE_NETWORKING@")
+if(_glaze_ENABLE_NETWORKING)
+ # vcpkg always uses standalone Asio, as declared in the port manifest.
+ # Preserve the documented networking interface without selecting Boost or
+ # downloading an undeclared dependency.
+ find_dependency(asio REQUIRED)
+ if(NOT TARGET glaze::asio)
+ add_library(glaze::asio INTERFACE IMPORTED)
+ set_property(TARGET glaze::asio PROPERTY INTERFACE_LINK_LIBRARIES asio::asio)
+ endif()
+
+ function(glaze_setup_asio)
+ endfunction()
+else()
+ function(glaze_setup_asio)
+ message(FATAL_ERROR "glaze_setup_asio() called but glaze was built without networking support")
+ endfunction()
+endif()
+unset(_glaze_ENABLE_NETWORKING)
+
# Handle SSL dependency (OpenSSL)
set(_glaze_ENABLE_SSL "@glaze_ENABLE_SSL@")
if(_glaze_ENABLE_SSL)
@@ -18,14 +38,3 @@ endif()
unset(_glaze_ENABLE_SSL)
include("${CMAKE_CURRENT_LIST_DIR}/glazeTargets.cmake")
-
-# Make the Asio backend selector available to networking consumers. This only
-# declares the glaze_USE_BUNDLED_ASIO option and the glaze_setup_asio() function;
-# nothing is resolved until the consumer calls glaze_setup_asio() and links
-# glaze::asio. Doing so picks the same backend and sets GLZ_USE_BOOST_ASIO exactly
-# as the in-tree build, so glaze/ext/glaze_asio.hpp can never disagree with the
-# linked Asio (issue #2599). Guarded so a source build without the installed
-# module (e.g. add_subdirectory) still configures.
-if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/glaze-asio.cmake")
- include("${CMAKE_CURRENT_LIST_DIR}/glaze-asio.cmake")
-endif()
diff --git a/cmake/install-rules.cmake b/cmake/install-rules.cmake
index cae895a7..42accbfc 100644
--- a/cmake/install-rules.cmake
+++ b/cmake/install-rules.cmake
@@ -38,13 +38,6 @@ mark_as_advanced(glaze_INSTALL_CMAKEDIR)
# in-tree builds. FindAsio.cmake travels with it because glaze_setup_asio()
# locates it via CMAKE_CURRENT_FUNCTION_LIST_DIR (issue #2599). glazeConfig.cmake
# includes glaze-asio.cmake so the function is available after find_package(glaze).
-install(
- FILES
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/glaze-asio.cmake"
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindAsio.cmake"
- DESTINATION "${glaze_INSTALL_CMAKEDIR}"
- COMPONENT glaze_Development
-)
# Read FindErlang.cmake content for embedding into config file
# This avoids installing a separate FindErlang.cmake that could collide with other projects