aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/xerces-c
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/xerces-c
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/xerces-c')
-rw-r--r--vcpkg/ports/xerces-c/dependencies.patch77
-rw-r--r--vcpkg/ports/xerces-c/disable-tests.patch21
-rw-r--r--vcpkg/ports/xerces-c/portfile.cmake82
-rw-r--r--vcpkg/ports/xerces-c/remove-dll-export-macro.patch27
-rw-r--r--vcpkg/ports/xerces-c/usage4
-rw-r--r--vcpkg/ports/xerces-c/vcpkg-cmake-wrapper.cmake8
-rw-r--r--vcpkg/ports/xerces-c/vcpkg.json39
7 files changed, 258 insertions, 0 deletions
diff --git a/vcpkg/ports/xerces-c/dependencies.patch b/vcpkg/ports/xerces-c/dependencies.patch
new file mode 100644
index 0000000..84f80c0
--- /dev/null
+++ b/vcpkg/ports/xerces-c/dependencies.patch
@@ -0,0 +1,77 @@
+diff --git a/cmake/XercesNetAccessorSelection.cmake b/cmake/XercesNetAccessorSelection.cmake
+index 7a63f1f..22ea65b 100644
+--- a/cmake/XercesNetAccessorSelection.cmake
++++ b/cmake/XercesNetAccessorSelection.cmake
+@@ -23,7 +23,7 @@ option(network "Network support" ON)
+
+ if(network)
+ find_library(SOCKET_LIBRARY socket)
+- find_library(NSL_LIBRARY nsl)
++ set(NSL_LIBRARY "" CACHE INTERNAL "Not used")
+
+ # netaccessors in order of preference
+
+diff --git a/cmake/XercesTranscoderSelection.cmake b/cmake/XercesTranscoderSelection.cmake
+index 4ff5b16..48e274c 100644
+--- a/cmake/XercesTranscoderSelection.cmake
++++ b/cmake/XercesTranscoderSelection.cmake
+@@ -25,6 +25,7 @@
+
+ if(ICU_FOUND)
+ list(APPEND transcoders icu)
++ set(TRANSCODER_REQUIRES "icu-uc")
+ endif()
+
+ # MacOS
+@@ -41,6 +42,20 @@ endif()
+
+ # GNU iconv
+
++if(NOT transcoder AND NOT transcoders AND NOT WIN32)
++ find_package(Iconv)
++ set(FIND_DEPENDENCY_ICONV "${Iconv_FOUND}")
++ if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
++ list(APPEND libxerces_c_DEPS Iconv::Iconv)
++ set(TRANSCODER_LIBS "-liconv -lcharset")
++ list(APPEND CMAKE_REQUIRED_LIBRARIES Iconv::Iconv)
++ include(CheckSymbolExists)
++ check_symbol_exists(iconv_open "iconv.h" HAVE_ICONV_OPEN)
++ check_symbol_exists(iconv_close "iconv.h" HAVE_ICONV_CLOSE)
++ check_symbol_exists(iconv "iconv.h" HAVE_ICONV)
++ endif()
++endif()
++
+ check_include_file_cxx(iconv.h HAVE_ICONV_H)
+ check_include_file_cxx(wchar.h HAVE_WCHAR_H)
+ check_include_file_cxx(string.h HAVE_STRING_H)
+diff --git a/src/XercesCConfig.cmake.in b/src/XercesCConfig.cmake.in
+index aa8fc2e..754c425 100644
+--- a/src/XercesCConfig.cmake.in
++++ b/src/XercesCConfig.cmake.in
+@@ -1,5 +1,14 @@
+ @PACKAGE_INIT@
+
++include(CMakeFindDependencyMacro)
++find_dependency(Threads)
++if("@CMAKE_REQUIRE_FIND_PACKAGE_ICU@")
++ find_dependency(ICU COMPONENTS uc data)
++endif()
++if("@FIND_DEPENDENCY_ICONV@")
++ find_dependency(Iconv)
++endif()
++
+ include(${CMAKE_CURRENT_LIST_DIR}/XercesCConfigInternal.cmake)
+
+ add_library(XercesC::XercesC INTERFACE IMPORTED)
+diff --git a/xerces-c.pc.in b/xerces-c.pc.in
+index 16b18c7..077296b 100644
+--- a/xerces-c.pc.in
++++ b/xerces-c.pc.in
+@@ -7,5 +7,6 @@ Name: Xerces-C++
+ Description: Validating XML parser library for C++
+ Version: @VERSION@
+ Libs: -L${libdir} -lxerces-c
+-Libs.private: @CURL_LIBS@
++Libs.private: @CURL_LIBS@ @TRANSCODER_LIBS@
++Requires.private: @TRANSCODER_REQUIRES@
+ Cflags: -I${includedir}
diff --git a/vcpkg/ports/xerces-c/disable-tests.patch b/vcpkg/ports/xerces-c/disable-tests.patch
new file mode 100644
index 0000000..843b022
--- /dev/null
+++ b/vcpkg/ports/xerces-c/disable-tests.patch
@@ -0,0 +1,21 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4254f89..aa08565 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -175,10 +175,16 @@ install(
+ COMPONENT "development")
+
+ # Process subdirectories
++if(NOT DISABLE_DOC)
+ add_subdirectory(doc)
++endif()
+ add_subdirectory(src)
++if(NOT DISABLE_TESTS)
+ add_subdirectory(tests)
++endif()
++if(NOT DISABLE_SAMPLES)
+ add_subdirectory(samples)
++endif()
+
+ # Display configuration summary
+ message(STATUS "")
diff --git a/vcpkg/ports/xerces-c/portfile.cmake b/vcpkg/ports/xerces-c/portfile.cmake
new file mode 100644
index 0000000..f9c9932
--- /dev/null
+++ b/vcpkg/ports/xerces-c/portfile.cmake
@@ -0,0 +1,82 @@
+vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO apache/xerces-c
+ REF "v${VERSION}"
+ SHA512 228f7b35ca219a2d5202b853983fd2941325413724f9cfbb8d0056bb81669c4530a792323f60736e4f6bf2c4f289fab21d6e2107e9ba65438437ae19b374b4a8
+ HEAD_REF master
+ PATCHES
+ dependencies.patch
+ disable-tests.patch
+ remove-dll-export-macro.patch
+)
+file(REMOVE "${SOURCE_PATH}/cmake/FindICU.cmake")
+
+vcpkg_check_features(
+ OUT_FEATURE_OPTIONS options
+ FEATURES
+ icu CMAKE_REQUIRE_FIND_PACKAGE_ICU
+ network network
+ INVERTED_FEATURES
+ icu CMAKE_DISABLE_FIND_PACKAGE_ICU
+)
+if("icu" IN_LIST FEATURES)
+ vcpkg_list(APPEND options -Dtranscoder=icu)
+elseif(VCPKG_TARGET_IS_WINDOWS)
+ vcpkg_list(APPEND options -Dtranscoder=windows)
+elseif(VCPKG_TARGET_IS_OSX)
+ vcpkg_list(APPEND options -Dtranscoder=macosunicodeconverter)
+elseif(VCPKG_HOST_IS_OSX)
+ # Because of a bug in the transcoder selection script, the option
+ # "macosunicodeconverter" is always selected when building on macOS,
+ # regardless of the target platform. This breaks cross-compiling.
+ # As a workaround we force "iconv", which should at least work for iOS.
+ # Upstream fix: https://github.com/apache/xerces-c/pull/52
+ vcpkg_list(APPEND options -Dtranscoder=iconv)
+else()
+ # xercesc chooses gnuiconv or iconv (cmake/XercesTranscoderSelection.cmake)
+endif()
+if("xmlch-wchar" IN_LIST FEATURES)
+ vcpkg_list(APPEND options -Dxmlch-type=wchar_t)
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DDISABLE_TESTS=ON
+ -DDISABLE_DOC=ON
+ -DDISABLE_SAMPLES=ON
+ -DCMAKE_DISABLE_FIND_PACKAGE_CURL=ON
+ ${options}
+ MAYBE_UNUSED_VARIABLES
+ CMAKE_DISABLE_FIND_PACKAGE_CURL
+)
+
+vcpkg_cmake_install()
+
+vcpkg_copy_pdbs()
+
+if(VCPKG_TARGET_IS_WINDOWS)
+ vcpkg_cmake_config_fixup(CONFIG_PATH cmake PACKAGE_NAME xercesc)
+else()
+ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/XercesC PACKAGE_NAME xercesc)
+endif()
+
+configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/xercesc/vcpkg-cmake-wrapper.cmake" @ONLY)
+
+file(REMOVE_RECURSE
+ "${CURRENT_PACKAGES_DIR}/debug/include"
+ "${CURRENT_PACKAGES_DIR}/debug/share"
+)
+
+vcpkg_fixup_pkgconfig()
+if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/xerces-c.pc" "-lxerces-c" "-lxerces-c_3")
+ if(NOT VCPKG_BUILD_TYPE)
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/xerces-c.pc" "-lxerces-c" "-lxerces-c_3D")
+ endif()
+endif()
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
+
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
diff --git a/vcpkg/ports/xerces-c/remove-dll-export-macro.patch b/vcpkg/ports/xerces-c/remove-dll-export-macro.patch
new file mode 100644
index 0000000..f6f0e69
--- /dev/null
+++ b/vcpkg/ports/xerces-c/remove-dll-export-macro.patch
@@ -0,0 +1,27 @@
+diff --git a/src/xercesc/util/XercesDefs.hpp b/src/xercesc/util/XercesDefs.hpp
+index 8071260..cd6bd68 100644
+--- a/src/xercesc/util/XercesDefs.hpp
++++ b/src/xercesc/util/XercesDefs.hpp
+@@ -133,7 +133,7 @@ typedef XMLUInt32 UCS4Ch;
+ // The DLL_EXPORT flag should be defined on the command line during the build of a DLL
+ // configure conspires to make this happen.
+
+-#if defined(DLL_EXPORT)
++#if defined(XERCES_DLL_EXPORT)
+ #if defined(XERCES_BUILDING_LIBRARY)
+ #define XMLUTIL_EXPORT XERCES_PLATFORM_EXPORT
+ #define XMLPARSER_EXPORT XERCES_PLATFORM_EXPORT
+diff --git a/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in b/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in
+index e849e08..69fe3bf 100644
+--- a/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in
++++ b/src/xercesc/util/Xerces_autoconf_config.hpp.cmake.in
+@@ -85,9 +85,6 @@
+ #define XERCES_PLATFORM_EXPORT @XERCES_PLATFORM_EXPORT@
+ #define XERCES_PLATFORM_IMPORT @XERCES_PLATFORM_IMPORT@
+ #define XERCES_TEMPLATE_EXTERN @XERCES_TEMPLATE_EXTERN@
+-#ifdef XERCES_DLL_EXPORT
+-# define DLL_EXPORT
+-#endif
+
+ // ---------------------------------------------------------------------------
+ // Include standard headers, if available, that we may rely on below.
diff --git a/vcpkg/ports/xerces-c/usage b/vcpkg/ports/xerces-c/usage
new file mode 100644
index 0000000..70333bf
--- /dev/null
+++ b/vcpkg/ports/xerces-c/usage
@@ -0,0 +1,4 @@
+The package xerces-c is compatible with built-in CMake targets:
+
+ find_package(XercesC REQUIRED)
+ target_link_libraries(main PRIVATE XercesC::XercesC)
diff --git a/vcpkg/ports/xerces-c/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/xerces-c/vcpkg-cmake-wrapper.cmake
new file mode 100644
index 0000000..11e9289
--- /dev/null
+++ b/vcpkg/ports/xerces-c/vcpkg-cmake-wrapper.cmake
@@ -0,0 +1,8 @@
+_find_package(${ARGS})
+
+if (APPLE)
+ if (TARGET XercesC::XercesC)
+ set_property(TARGET XercesC::XercesC APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-framework CoreServices" "-framework CoreFoundation")
+ list(APPEND XercesC_LIBRARIES "-framework CoreServices" "-framework CoreFoundation")
+ endif()
+endif()
diff --git a/vcpkg/ports/xerces-c/vcpkg.json b/vcpkg/ports/xerces-c/vcpkg.json
new file mode 100644
index 0000000..01393bf
--- /dev/null
+++ b/vcpkg/ports/xerces-c/vcpkg.json
@@ -0,0 +1,39 @@
+{
+ "name": "xerces-c",
+ "version-semver": "3.3.0",
+ "description": "Xerces-C++ is a XML parser, for parsing, generating, manipulating, and validating XML documents using the DOM, SAX, and SAX2 APIs.",
+ "homepage": "https://github.com/apache/xerces-c",
+ "license": "Apache-2.0",
+ "supports": "!uwp",
+ "dependencies": [
+ {
+ "name": "libiconv",
+ "platform": "!windows & !osx"
+ },
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ],
+ "default-features": [
+ "network"
+ ],
+ "features": {
+ "icu": {
+ "description": "ICU support",
+ "dependencies": [
+ "icu"
+ ]
+ },
+ "network": {
+ "description": "Network support"
+ },
+ "xmlch-wchar": {
+ "description": "XMLCh type uses wchar_t"
+ }
+ }
+}