Skip to content

Commit

Permalink
Merge pull request #18441 from Michael-Gardner/9.6.0-overlay
Browse files Browse the repository at this point in the history
HPCC-31462 Libxml2 and libxslt vcpkg_overlay for xinclude documentations issue
  • Loading branch information
GordonSmith authored Mar 25, 2024
2 parents bc2601d + 3e31302 commit 3270ca6
Show file tree
Hide file tree
Showing 15 changed files with 539 additions and 0 deletions.
20 changes: 20 additions & 0 deletions vcpkg_overlays/libxml2/disable-docs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f922d5ab..70466bc7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -599,15 +599,5 @@ if(LIBXML2_WITH_PYTHON)
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
108 changes: 108 additions & 0 deletions vcpkg_overlays/libxml2/fix_cmakelist.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f922d5ab..685964b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -420,15 +420,15 @@ endif()
if(LIBXML2_WITH_ICU)
target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
if(WIN32)
- set(ICU_LIBS "-licudt -licuin -licuuc")
+ set(ICU_LIBS "icu-i18n")
else()
- set(ICU_LIBS "-licudata -licui18n -licuuc")
+ set(ICU_LIBS "icu-i18n")
endif()
endif()

if(LIBXML2_WITH_LZMA)
target_link_libraries(LibXml2 PRIVATE LibLZMA::LibLZMA)
- set(LZMA_LIBS "-llzma")
+ set(LZMA_LIBS "liblzma")
endif()

if(LIBXML2_WITH_THREADS)
@@ -438,7 +438,7 @@ endif()

if(LIBXML2_WITH_ZLIB)
target_link_libraries(LibXml2 PRIVATE ZLIB::ZLIB)
- set(Z_LIBS "-lz")
+ set(Z_LIBS "zlib")
endif()

set_target_properties(
@@ -490,23 +490,9 @@ set_target_properties(
SOVERSION ${LIBXML_MAJOR_VERSION}
)

+set(XML_LIB_NAME xml2)
if(MSVC)
- if(BUILD_SHARED_LIBS)
- set_target_properties(
- LibXml2
- PROPERTIES
- DEBUG_POSTFIX d
- )
- else()
- set_target_properties(
- LibXml2
- PROPERTIES
- DEBUG_POSTFIX sd
- MINSIZEREL_POSTFIX s
- RELEASE_POSTFIX s
- RELWITHDEBINFO_POSTFIX s
- )
- endif()
+ set(XML_LIB_NAME libxml2)
endif()

install(FILES ${LIBXML2_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
@@ -654,30 +640,30 @@ install(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libxml2 COMPONEN

configure_package_config_file(
libxml2-config.cmake.cmake.in libxml2-config.cmake
- INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config.cmake
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
COMPONENT development
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
VERSION ${PROJECT_VERSION}
- COMPATIBILITY ExactVersion
+ COMPATIBILITY SameMinorVersion
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
COMPONENT development
)

install(
EXPORT LibXml2
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
NAMESPACE LibXml2::
FILE libxml2-export.cmake
COMPONENT development
diff --git a/libxml-2.0.pc.in b/libxml-2.0.pc.in
index 2653a7c5..2eb2f362 100644
--- a/libxml-2.0.pc.in
+++ b/libxml-2.0.pc.in
@@ -8,6 +8,7 @@ Name: libXML
Version: @VERSION@
Description: libXML library version2.
Requires:
-Libs: -L${libdir} @XML_LIBS@
-Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
+Requires.private: @ICU_LIBS@ @Z_LIBS@ @LZMA_LIBS@
+Libs: -L${libdir} -l@XML_LIB_NAME@
+Libs.private: @THREAD_LIBS@ @ICONV_LIBS@ @LIBM@ @WIN32_EXTRA_LIBADD@ @LIBS@
Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
90 changes: 90 additions & 0 deletions vcpkg_overlays/libxml2/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
vcpkg_from_gitlab(
GITLAB_URL https://gitlab.gnome.org/
OUT_SOURCE_PATH SOURCE_PATH
REPO GNOME/libxml2
REF f507d167f1755b7eaea09fb1a44d29aab828b6d1
SHA512 2ac3dcab31111f608a3fe33dde492c9653ad2bd49a792373acdd03d2787e1a4ef70eeb7a3d47cf67eefd43aee2ab75ec50b36cdcd124445ca206de924abb6021
HEAD_REF master
PATCHES
disable-docs.patch
fix_cmakelist.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
)
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_ICU=OFF # Culprit of linkage issues? Solving this is probably another PR
-DLIBXML2_WITH_MEM_DEBUG=OFF
-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_RUN_DEBUG=OFF
-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
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/libxml2")
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}"
)
file(INSTALL "${SOURCE_PATH}/Copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
4 changes: 4 additions & 0 deletions vcpkg_overlays/libxml2/usage
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions vcpkg_overlays/libxml2/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
list(REMOVE_ITEM ARGS "NO_MODULE" "CONFIG" "MODULE")
_find_package(${ARGS} CONFIG)
set(LIBXML2_FOUND "${LibXml2_FOUND}") # fphsa compatibility
57 changes: 57 additions & 0 deletions vcpkg_overlays/libxml2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "libxml2",
"version": "2.10.3",
"port-version": 1,
"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"
]
},
"legacy": {
"description": "Add deprecated APIs for compatibility"
},
"lzma": {
"description": "Use LZMA",
"dependencies": [
"liblzma"
]
},
"tools": {
"description": "Build tools"
},
"zlib": {
"description": "Use ZLib",
"dependencies": [
"zlib"
]
}
}
}
45 changes: 45 additions & 0 deletions vcpkg_overlays/libxslt/fix-gcrypt-deps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dc6501..d36a049 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -317,7 +317,9 @@ target_include_directories(

if(LIBXSLT_WITH_CRYPTO AND NOT WIN32)
target_link_libraries(LibExslt PRIVATE Gcrypt::Gcrypt)
- set(LIBGCRYPT_LIBS "-lgcrypt")
+ # For libexslt.pc
+ set(LIBGCRYPT_LIBS "")
+ string(APPEND EXSLT_PRIVATE_REQUIRES " libgcrypt")
endif()

target_link_libraries(LibExslt PUBLIC LibXslt LibXml2::LibXml2)
diff --git a/FindGcrypt.cmake b/FindGcrypt.cmake
index 781113d..a78fa84 100644
--- a/FindGcrypt.cmake
+++ b/FindGcrypt.cmake
@@ -1,3 +1,20 @@
+cmake_policy(PUSH)
+cmake_policy(SET CMP0012 NEW)
+cmake_policy(SET CMP0057 NEW)
+find_package(PkgConfig)
+if("REQUIRED" IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ pkg_check_modules(libxslt_gcrypt REQUIRED IMPORTED_TARGET libgcrypt)
+else()
+ pkg_check_modules(libxslt_gcrypt IMPORTED_TARGET libgcrypt)
+endif()
+set(Gcrypt_FOUND "${libxslt_gcrypt_FOUND}") # CMake standard, needed for find_dependency
+set(GCRYPT_FOUND "${libxslt_gcrypt_FOUND}") # libxslt usage
+if(libxslt_gcrypt_FOUND AND NOT TARGET Gcrypt::Gcrypt)
+ add_library(Gcrypt::Gcrypt INTERFACE IMPORTED)
+ set_target_properties(Gcrypt::Gcrypt PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::libxslt_gcrypt)
+endif()
+cmake_policy(POP)
+if(0)
include(FindPackageHandleStandardArgs)
include(SelectLibraryConfigurations)

@@ -38,3 +53,4 @@ if(GCRYPT_FOUND AND NOT TARGET Gcrypt::Gcrypt)
INTERFACE_INCLUDE_DIRECTORIES "${GCRYPT_INCLUDE_DIRS}"
)
endif()
+endif()
14 changes: 14 additions & 0 deletions vcpkg_overlays/libxslt/libexslt-pkgconfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/libexslt.pc.in b/libexslt.pc.in
index 1d60563..50089e8 100644
--- a/libexslt.pc.in
+++ b/libexslt.pc.in
@@ -7,7 +7,8 @@ includedir=@includedir@
Name: libexslt
Version: @LIBEXSLT_VERSION@
Description: EXSLT Extension library
-Requires: libxml-2.0, libxslt
+Requires: libxslt
+Requires.private: @EXSLT_PRIVATE_REQUIRES@
Cflags: @EXSLT_INCLUDEDIR@
Libs: @EXSLT_LIBDIR@ -lexslt
Libs.private: @EXSLT_PRIVATE_LIBS@
22 changes: 22 additions & 0 deletions vcpkg_overlays/libxslt/msvc-no-suffix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8679fb..6dc6501 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -244,7 +249,7 @@ set_target_properties(
VERSION ${PROJECT_VERSION}
)

-if(MSVC)
+if(0) # Never add suffixes which are not added by the autotools build or the nmake makefiles
if(BUILD_SHARED_LIBS)
set_target_properties(
LibXslt
@@ -327,7 +332,7 @@ set_target_properties(
VERSION ${LIBEXSLT_VERSION}
)

-if(MSVC)
+if(0) # same reason as above
if(BUILD_SHARED_LIBS)
set_target_properties(
LibExslt
Loading

0 comments on commit 3270ca6

Please sign in to comment.