diff --git a/vcpkg/ports/libxml2/disable-docs.patch b/vcpkg/ports/libxml2/disable-docs.patch new file mode 100644 index 0000000000..15ab0a6c2c --- /dev/null +++ b/vcpkg/ports/libxml2/disable-docs.patch @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f99fd368..38dcd377 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -586,17 +586,6 @@ if(LIBXML2_WITH_PYTHON) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime) + endif() + +-install(FILES doc/xml2-config.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation) +-install(FILES doc/xmlcatalog.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation) +-install(FILES doc/xmllint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation) +-install(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT documentation +- PATTERN "Makefile.*" EXCLUDE +- PATTERN "*.1" EXCLUDE +- PATTERN "*.py" EXCLUDE +- PATTERN "*.res" EXCLUDE +- PATTERN "*.xml" EXCLUDE +- PATTERN "*.xsl" EXCLUDE) +- + configure_package_config_file( + libxml2-config.cmake.cmake.in libxml2-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION} diff --git a/vcpkg/ports/libxml2/fix_cmakelist.patch b/vcpkg/ports/libxml2/fix_cmakelist.patch new file mode 100644 index 0000000000..e450b2d95f --- /dev/null +++ b/vcpkg/ports/libxml2/fix_cmakelist.patch @@ -0,0 +1,34 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f99fd368..3246a42c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -438,7 +438,7 @@ set_target_properties( + SOVERSION ${LIBXML_MAJOR_VERSION} + ) + +-if(MSVC) ++if(0) + if(BUILD_SHARED_LIBS) + set_target_properties( + LibXml2 +@@ -653,7 +653,11 @@ list(JOIN XML_PRIVATE_LIBS " " XML_PRIVATE_LIBS) + + set(XML_INCLUDEDIR "-I\${includedir}/libxml2") + set(XML_LIBDIR "-L\${libdir}") ++if(NOT MSVC) + set(XML_LIBS "-lxml2") ++else() ++set(XML_LIBS "-llibxml2") ++endif() + + if(BUILD_SHARED_LIBS) + set(XML_PC_PRIVATE ".private") +@@ -679,7 +683,7 @@ set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + configure_file(libxml-2.0.pc.in libxml-2.0.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml-2.0.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development) + +-if(WIN32) ++if(1) + set(prefix "\$(cd \"\$(dirname \"\$0\")\"; pwd -P)/..") + endif() + configure_file(xml2-config.in xml2-config @ONLY) diff --git a/vcpkg/ports/libxml2/fix_ios_compilation.patch b/vcpkg/ports/libxml2/fix_ios_compilation.patch new file mode 100644 index 0000000000..c38896fd42 --- /dev/null +++ b/vcpkg/ports/libxml2/fix_ios_compilation.patch @@ -0,0 +1,119 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0a279c8..8e771ee 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -136,7 +136,7 @@ if (NOT MSVC) + check_include_files(fcntl.h HAVE_FCNTL_H) + check_function_exists(fpclass HAVE_FPCLASS) + check_function_exists(ftime HAVE_FTIME) +- check_function_exists(getentropy HAVE_GETENTROPY) ++ check_symbol_exists(getentropy "sys/random.h" HAVE_DECL_GETENTROPY) + check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) + check_library_exists(history append_history "" HAVE_LIBHISTORY) + check_library_exists(readline readline "" HAVE_LIBREADLINE) +@@ -149,7 +149,6 @@ if (NOT MSVC) + check_function_exists(stat HAVE_STAT) + check_include_files(stdint.h HAVE_STDINT_H) + check_include_files(sys/mman.h HAVE_SYS_MMAN_H) +- check_include_files(sys/random.h HAVE_SYS_RANDOM_H) + check_include_files(sys/select.h HAVE_SYS_SELECT_H) + check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) + check_include_files(sys/stat.h HAVE_SYS_STAT_H) +diff --git a/config.h.cmake.in b/config.h.cmake.in +index 2f4aeba..79f1cdb 100644 +--- a/config.h.cmake.in ++++ b/config.h.cmake.in +@@ -23,7 +23,7 @@ + #cmakedefine HAVE_FTIME 1 + + /* Define to 1 if you have the `getentropy' function. */ +-#cmakedefine HAVE_GETENTROPY 1 ++#cmakedefine HAVE_DECL_GETENTROPY 1 + + /* Define to 1 if you have the `gettimeofday' function. */ + #cmakedefine HAVE_GETTIMEOFDAY 1 +@@ -69,9 +69,6 @@ + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_SYS_MMAN_H 1 + +-/* Define to 1 if you have the header file. */ +-#cmakedefine HAVE_SYS_RANDOM_H 1 +- + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_SYS_SELECT_H 1 + +diff --git a/configure.ac b/configure.ac +index 48cd2f0..0f09c61 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -304,7 +304,6 @@ AC_CHECK_HEADERS([stdint.h]) + AC_CHECK_HEADERS([fcntl.h unistd.h sys/stat.h]) + AC_CHECK_HEADERS([sys/mman.h]) + AC_CHECK_HEADERS([sys/time.h sys/timeb.h]) +-AC_CHECK_HEADERS([sys/random.h]) + AC_CHECK_HEADERS([dl.h dlfcn.h]) + AC_CHECK_HEADERS([glob.h]) + AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes") +@@ -317,9 +316,7 @@ AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */ + # undef /**/ HAVE_MMAP + #endif]) + +-AC_CHECK_DECL([getentropy], +- [AC_DEFINE([HAVE_GETENTROPY], [1], [getentropy])], [], +- [#include ]) ++AC_CHECK_DECLS([getentropy], [], [], [#include ]) + + dnl + dnl Checks for inet libraries +diff --git a/dict.c b/dict.c +index 49e1c6b..46bb4d4 100644 +--- a/dict.c ++++ b/dict.c +@@ -928,13 +928,11 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) { + #define WIN32_LEAN_AND_MEAN + #include + #include +-#elif defined(HAVE_GETENTROPY) ++#elif HAVE_DECL_GETENTROPY + #ifdef HAVE_UNISTD_H + #include + #endif +- #ifdef HAVE_SYS_RANDOM_H +- #include +- #endif ++ #include + #else + #include + #endif +@@ -965,7 +963,7 @@ xmlInitRandom(void) { + "error code %lu\n", GetLastError()); + abort(); + } +-#elif defined(HAVE_GETENTROPY) ++#elif HAVE_DECL_GETENTROPY + while (1) { + if (getentropy(globalRngState, sizeof(globalRngState)) == 0) + break; +diff --git a/meson.build b/meson.build +index b6939c7..bbee96d 100644 +--- a/meson.build ++++ b/meson.build +@@ -314,13 +314,15 @@ xml_check_functions = [ + ['gettimeofday', 'sys/time.h'], + ['ftime', 'sys/timeb.h'], + ['stat', 'sys/stat.h'], +- ['mmap', 'sys/mman.h'], +- ['munmap', 'sys/mman.h'], ++ ['getentropy', 'sys/random.h', 'HAVE_DECL_GETENTROPY'], ++ ['mmap', 'sys/mman.h', 'HAVE_MMAP'], ++ ['munmap', 'sys/mman.h', 'HAVE_MUNMAP'], ++ + ] + + foreach function : xml_check_functions + if cc.has_header_symbol(function[1], function[0]) +- config_h.set10('HAVE_' + function[0].to_upper(), true) ++ config_h.set10(function[2], true) + endif + endforeach + diff --git a/vcpkg/ports/libxml2/portfile.cmake b/vcpkg/ports/libxml2/portfile.cmake new file mode 100644 index 0000000000..e62bc9d2a4 --- /dev/null +++ b/vcpkg/ports/libxml2/portfile.cmake @@ -0,0 +1,106 @@ +vcpkg_download_distfile(FIX_COMPATIBILITY_PATCH + URLS https://github.com/GNOME/libxml2/commit/b347a008a745778630a9eb4fbd29694f3c135bfa.diff?full_index=1 + FILENAME Fix-compatibility-in-package-version-file.patch + SHA512 7f5e5f53444c12924b0fefdf3013fa4dab76fb17f552dd827628739a6e65c9817ae7182e1817cea2317e2fc9b8a200ecce4f8cb5661a2614c0548a5b3e508b66 +) + +vcpkg_download_distfile(ADD_MISSING_BCRYPT_PATCH + URLS https://github.com/GNOME/libxml2/commit/fe1ee0f25f43e33a9981fd6fe7b0483a8c8b5e8d.diff?full_index=1 + FILENAME Add-missing-Bcrypt-link.patch + SHA512 22bc2fe4c365a2c9991508484daa3d884ff91803df48b3847f71b2283e240ef3ce4fdc1d230932d837ff94dc02fc53e76e2e5a1c956ef037caacb13d8f9b3982 +) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO GNOME/libxml2 + REF "v${VERSION}" + SHA512 dfe0529dd2fbb7dc9e79505b9c6ff7f29979fa4392d534c1b8859fa9934c2e7d4da3429265d718292056809a58080af32b130263625cdeb358123774c27da7c6 + HEAD_REF master + PATCHES + disable-docs.patch + fix_cmakelist.patch + fix_ios_compilation.patch + ${FIX_COMPATIBILITY_PATCH} + ${ADD_MISSING_BCRYPT_PATCH} +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + "ftp" LIBXML2_WITH_FTP + "http" LIBXML2_WITH_HTTP + "iconv" LIBXML2_WITH_ICONV + "legacy" LIBXML2_WITH_LEGACY + "lzma" LIBXML2_WITH_LZMA + "zlib" LIBXML2_WITH_ZLIB + "tools" LIBXML2_WITH_PROGRAMS + "icu" LIBXML2_WITH_ICU +) + +vcpkg_find_acquire_program(PKGCONFIG) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DLIBXML2_WITH_TESTS=OFF + -DLIBXML2_WITH_HTML=ON + -DLIBXML2_WITH_C14N=ON + -DLIBXML2_WITH_CATALOG=ON + -DLIBXML2_WITH_DEBUG=ON + -DLIBXML2_WITH_ISO8859X=ON + -DLIBXML2_WITH_MODULES=ON + -DLIBXML2_WITH_OUTPUT=ON + -DLIBXML2_WITH_PATTERN=ON + -DLIBXML2_WITH_PUSH=ON + -DLIBXML2_WITH_PYTHON=OFF + -DLIBXML2_WITH_READER=ON + -DLIBXML2_WITH_REGEXPS=ON + -DLIBXML2_WITH_SAX1=ON + -DLIBXML2_WITH_SCHEMAS=ON + -DLIBXML2_WITH_SCHEMATRON=ON + -DLIBXML2_WITH_THREADS=ON + -DLIBXML2_WITH_THREAD_ALLOC=OFF + -DLIBXML2_WITH_TREE=ON + -DLIBXML2_WITH_VALID=ON + -DLIBXML2_WITH_WRITER=ON + -DLIBXML2_WITH_XINCLUDE=ON + -DLIBXML2_WITH_XPATH=ON + -DLIBXML2_WITH_XPTR=ON + "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}" +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/libxml2-${VERSION}") +vcpkg_fixup_pkgconfig() + +vcpkg_copy_pdbs() + +if("tools" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES xmllint xmlcatalog AUTO_CLEAN) +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + set(_file "${CURRENT_PACKAGES_DIR}/include/libxml2/libxml/xmlexports.h") + file(READ "${_file}" _contents) + string(REPLACE "#ifdef LIBXML_STATIC" "#undef LIBXML_STATIC\n#define LIBXML_STATIC\n#ifdef LIBXML_STATIC" _contents "${_contents}") + file(WRITE "${_file}" "${_contents}") +endif() + +file(COPY "${CURRENT_PACKAGES_DIR}/include/libxml2/" DESTINATION "${CURRENT_PACKAGES_DIR}/include") # TODO: Fix usage in all dependent ports hardcoding the wrong include path. + +# Cleanup +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/xml2Conf.sh" "${CURRENT_PACKAGES_DIR}/debug/lib/xml2Conf.sh") + +file(COPY + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" + "${CMAKE_CURRENT_LIST_DIR}/usage" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" +) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/Copyright") diff --git a/vcpkg/ports/libxml2/usage b/vcpkg/ports/libxml2/usage new file mode 100644 index 0000000000..c7a4878e9b --- /dev/null +++ b/vcpkg/ports/libxml2/usage @@ -0,0 +1,4 @@ +The package libxml2 is compatible with built-in CMake targets: + + find_package(LibXml2 REQUIRED) + target_link_libraries(main PRIVATE LibXml2::LibXml2) diff --git a/vcpkg/ports/libxml2/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/libxml2/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000000..705f22c6a3 --- /dev/null +++ b/vcpkg/ports/libxml2/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,3 @@ +list(REMOVE_ITEM ARGS "NO_MODULE" "CONFIG" "MODULE") +_find_package(${ARGS} CONFIG) +set(LIBXML2_FOUND "${LibXml2_FOUND}") # fphsa compatibility diff --git a/vcpkg/ports/libxml2/vcpkg.json b/vcpkg/ports/libxml2/vcpkg.json new file mode 100644 index 0000000000..2e8ba05ad4 --- /dev/null +++ b/vcpkg/ports/libxml2/vcpkg.json @@ -0,0 +1,62 @@ +{ + "name": "libxml2", + "version": "2.13.5", + "description": "Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform).", + "homepage": "https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home", + "license": "MIT", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "iconv", + "lzma", + "zlib" + ], + "features": { + "ftp": { + "description": "Add the FTP support", + "supports": "!uwp" + }, + "http": { + "description": "Add the HTTP support", + "supports": "!uwp" + }, + "iconv": { + "description": "Add ICONV support", + "dependencies": [ + "libiconv" + ] + }, + "icu": { + "description": "Add ICU support", + "dependencies": [ + "icu" + ] + }, + "legacy": { + "description": "Add deprecated APIs for compatibility" + }, + "lzma": { + "description": "Use LZMA", + "dependencies": [ + "liblzma" + ] + }, + "tools": { + "description": "Build tools" + }, + "zlib": { + "description": "Use ZLib", + "dependencies": [ + "zlib" + ] + } + } +}