From 5737466a31830c017867e3831a329c8f605c877b Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 23 Nov 2024 15:49:04 +0100 Subject: [PATCH] cmake: Only link with winsock2 if HTTP is enabled --- CMakeLists.txt | 6 ++++-- libxml2-config.cmake.cmake.in | 6 +++++- libxml2-config.cmake.in | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df30693c..7c2b0e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,10 +344,12 @@ if(UNIX) endif() if(WIN32) - target_link_libraries(LibXml2 PRIVATE ws2_32) - set(WINSOCK_LIBS "-lws2_32") target_link_libraries(LibXml2 PRIVATE bcrypt) set(CRYPTO_LIBS "-lbcrypt") + if(LIBXML2_WITH_HTTP) + target_link_libraries(LibXml2 PRIVATE ws2_32) + set(WINSOCK_LIBS "-lws2_32") + endif() endif() if(LIBXML2_WITH_ICONV) diff --git a/libxml2-config.cmake.cmake.in b/libxml2-config.cmake.cmake.in index f1b5676a..de084bdf 100644 --- a/libxml2-config.cmake.cmake.in +++ b/libxml2-config.cmake.cmake.in @@ -97,6 +97,7 @@ set(LIBXML2_WITH_THREADS @LIBXML2_WITH_THREADS@) set(LIBXML2_WITH_ICU @LIBXML2_WITH_ICU@) set(LIBXML2_WITH_LZMA @LIBXML2_WITH_LZMA@) set(LIBXML2_WITH_ZLIB @LIBXML2_WITH_ZLIB@) +set(LIBXML2_WITH_HTTP @LIBXML2_WITH_HTTP@) if(LIBXML2_WITH_ICONV) find_dependency(Iconv) @@ -157,7 +158,10 @@ if(NOT LIBXML2_SHARED) endif() if(WIN32) - list(APPEND LIBXML2_LIBRARIES ws2_32;Bcrypt) + list(APPEND LIBXML2_LIBRARIES Bcrypt) + if(LIBXML2_WITH_HTTP) + list(APPEND LIBXML2_LIBRARIES ws2_32) + endif() endif() endif() diff --git a/libxml2-config.cmake.in b/libxml2-config.cmake.in index d128cd20..31036805 100644 --- a/libxml2-config.cmake.in +++ b/libxml2-config.cmake.in @@ -50,6 +50,7 @@ set(LIBXML2_WITH_THREADS @WITH_THREADS@) set(LIBXML2_WITH_ICU @WITH_ICU@) set(LIBXML2_WITH_LZMA @WITH_LZMA@) set(LIBXML2_WITH_ZLIB @WITH_ZLIB@) +set(LIBXML2_WITH_HTTP @WITH_HTTP@) if(LIBXML2_WITH_ICONV) find_dependency(Iconv) @@ -113,8 +114,12 @@ if(UNIX) endif() if(WIN32) - list(APPEND LIBXML2_LIBRARIES ws2_32;Bcrypt) - list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$;\$") + list(APPEND LIBXML2_LIBRARIES Bcrypt) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + if(LIBXML2_WITH_HTTP) + list(APPEND LIBXML2_LIBRARIES ws2_32) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$") + endif() endif() # whether libxml2 has dso support