MINIFICPP-2637 Upgrade libxml2 to v2.15.0
Signed-off-by: Ferenc Gerlits <fgerlits@gmail.com>
Closes #2036
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1c37bb..0d36e94 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -370,12 +370,6 @@
add_subdirectory(extension-framework)
add_subdirectory(libminifi)
-if (ENABLE_ALL OR ENABLE_AZURE)
- include(GetLibXml2)
- get_libxml2(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/libxml2/dummy")
-endif()
-
if (ENABLE_ALL OR ENABLE_PROMETHEUS OR ENABLE_GRAFANA_LOKI OR ENABLE_CIVET)
include(GetCivetWeb)
get_civetweb()
diff --git a/cmake/AzureSdkCpp.cmake b/cmake/AzureSdkCpp.cmake
index 375785a..d7d616e 100644
--- a/cmake/AzureSdkCpp.cmake
+++ b/cmake/AzureSdkCpp.cmake
@@ -29,6 +29,12 @@
FetchContent_MakeAvailable(wil)
endif()
+if (NOT WIN32)
+ include(GetLibXml2)
+ get_libxml2(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/libxml2/dummy")
+endif()
+
set(WARNINGS_AS_ERRORS OFF CACHE INTERNAL "")
set(DISABLE_AZURE_CORE_OPENTELEMETRY ON CACHE INTERNAL "")
set(BUILD_TRANSPORT_CURL ON CACHE INTERNAL "")
@@ -55,3 +61,8 @@
)
FetchContent_MakeAvailable(asdkext)
+
+if (NOT WIN32)
+ add_dependencies(azure-storage-common LibXml2::LibXml2)
+ add_dependencies(azure-data-tables LibXml2::LibXml2)
+endif()
diff --git a/cmake/BundledLibXml2.cmake b/cmake/BundledLibXml2.cmake
deleted file mode 100644
index 5ab5a74..0000000
--- a/cmake/BundledLibXml2.cmake
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-function(use_bundled_libxml2 SOURCE_DIR BINARY_DIR)
- message("Using bundled libxml2")
-
- # Define patch step
- if (WIN32)
- set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libxml2/libxml2-win.patch")
- endif()
-
- # Define byproducts
- if (WIN32)
- set(BYPRODUCT "lib/xml2.lib")
- else()
- set(BYPRODUCT "lib/libxml2.a")
- endif()
-
- # Set build options
- if (WIN32)
- set(LIBXML2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS}
- "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libxml2-install")
- endif()
-
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
- cmake_policy(SET CMP0135 OLD) # Restore the timestamps from the archive https://gitlab.kitware.com/cmake/cmake/-/issues/24003
- endif()
-
- # Build project
- set(LIBXML2_URL ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz https://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/libxml2-2.9.10.tar.gz)
- set(LIBXML2_URL_HASH "SHA256=aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f")
-
- if (WIN32)
- ExternalProject_Add(
- libxml2-external
- URL ${LIBXML2_URL}
- URL_HASH ${LIBXML2_URL_HASH}
- SOURCE_DIR "${BINARY_DIR}/thirdparty/libxml2-src"
- LIST_SEPARATOR % # This is needed for passing semicolon-separated lists
- CMAKE_ARGS ${LIBXML2_CMAKE_ARGS}
- PATCH_COMMAND ${PC}
- BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}"
- EXCLUDE_FROM_ALL TRUE
- DOWNLOAD_NO_PROGRESS TRUE
- TLS_VERIFY TRUE
- )
- else()
- ExternalProject_Add(
- libxml2-external
- URL ${LIBXML2_URL}
- URL_HASH ${LIBXML2_URL_HASH}
- BUILD_IN_SOURCE true
- SOURCE_DIR "${BINARY_DIR}/thirdparty/libxml2-src"
- BUILD_COMMAND make
- CMAKE_COMMAND ""
- UPDATE_COMMAND ""
- INSTALL_COMMAND make install
- BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}"
- CONFIGURE_COMMAND ""
- PATCH_COMMAND ./configure --enable-shared=no --enable-static=yes --with-pic=yes --with-iconv=no --with-zlib=no --with-lzma=no --with-python=no --with-ftp=no --with-http=no --prefix=${BINARY_DIR}/thirdparty/libxml2-install
- STEP_TARGETS build
- EXCLUDE_FROM_ALL TRUE
- DOWNLOAD_NO_PROGRESS TRUE
- TLS_VERIFY TRUE
- )
- endif()
-
- # Set variables
- set(LIBXML2_FOUND "YES" CACHE STRING "" FORCE)
- set(LIBXML2_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libxml2-install/include/libxml2" CACHE STRING "" FORCE)
- set(LIBXML2_INCLUDE_DIRS "${LIBXML2_INCLUDE_DIR}" CACHE STRING "" FORCE)
- set(LIBXML2_LIBRARY "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" CACHE STRING "" FORCE)
- set(LIBXML2_LIBRARIES "${LIBXML2_LIBRARY}" CACHE STRING "" FORCE)
-
- # Set exported variables for FindPackage.cmake
- set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}" CACHE STRING "" FORCE)
- set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_LIBRARY=${LIBXML2_LIBRARY}" CACHE STRING "" FORCE)
-
- # Create imported targets
- file(MAKE_DIRECTORY ${LIBXML2_INCLUDE_DIR})
-
- add_library(LibXml2::LibXml2 STATIC IMPORTED)
- set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
- add_dependencies(LibXml2::LibXml2 libxml2-external)
- set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIR}")
-endfunction(use_bundled_libxml2)
diff --git a/cmake/GetLibXml2.cmake b/cmake/GetLibXml2.cmake
index 5915b11..2a6c618 100644
--- a/cmake/GetLibXml2.cmake
+++ b/cmake/GetLibXml2.cmake
@@ -21,7 +21,6 @@
find_package(libxml2 REQUIRED)
elseif(MINIFI_LIBXML2_SOURCE STREQUAL "BUILD")
message("Using CMake to build libxml2 from source")
- include(BundledLibXml2)
- use_bundled_libxml2(${SOURCE_DIR} ${BINARY_DIR})
+ include(LibXml2)
endif()
endfunction(get_libxml2)
diff --git a/cmake/LibXml2.cmake b/cmake/LibXml2.cmake
new file mode 100644
index 0000000..0e3f5d0
--- /dev/null
+++ b/cmake/LibXml2.cmake
@@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
+set(LIBXML2_WITH_DEBUG OFF CACHE BOOL "" FORCE)
+set(LIBXML2_WITH_PROGRAMS OFF CACHE BOOL "" FORCE)
+set(LIBXML2_WITH_TESTS OFF CACHE BOOL "" FORCE)
+set(LIBXML2_WITH_CATALOG OFF CACHE BOOL "" FORCE)
+set(LIBXML2_WITH_ICONV OFF CACHE BOOL "" FORCE)
+set(LIBXML2_WITH_ICU OFF CACHE BOOL "" FORCE)
+
+include(FetchContent)
+FetchContent_Declare(
+ libxml2
+ URL https://github.com/GNOME/libxml2/archive/refs/tags/v2.15.0.tar.gz
+ URL_HASH SHA256=e24bd5209afefe390e704ebc55649c7ae240e1f157cefd433ccc86c610d20aac
+ SYSTEM
+)
+FetchContent_MakeAvailable(libxml2)
+
+set(LIBXML2_FOUND "YES" CACHE STRING "" FORCE)
+set(LIBXML2_INCLUDE_DIRS
+ "${libxml2_SOURCE_DIR}/include"
+ "${libxml2_BINARY_DIR}"
+ CACHE STRING "" FORCE)
+if (WIN32)
+ if (CMAKE_GENERATOR STREQUAL "Ninja")
+ set(LIBXML2_LIBRARIES "${libxml2_BINARY_DIR}/libxml2s.lib" CACHE STRING "" FORCE)
+ set(LIBXML2_LIBRARY "${libxml2_BINARY_DIR}/libxml2s.lib" CACHE STRING "" FORCE)
+ else()
+ set(LIBXML2_LIBRARIES "${libxml2_BINARY_DIR}/${CMAKE_BUILD_TYPE}/libxml2s.lib" CACHE STRING "" FORCE)
+ set(LIBXML2_LIBRARY "${libxml2_BINARY_DIR}/${CMAKE_BUILD_TYPE}/libxml2s.lib" CACHE STRING "" FORCE)
+ endif()
+else()
+ set(LIBXML2_LIBRARIES "${libxml2_BINARY_DIR}/libxml2.a" CACHE STRING "" FORCE)
+ set(LIBXML2_LIBRARY "${libxml2_BINARY_DIR}/libxml2.a" CACHE STRING "" FORCE)
+endif()
+
+# Set exported variables for FindPackage.cmake
+set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_INCLUDE_DIRS=${LIBXML2_INCLUDE_DIRS}" CACHE STRING "" FORCE)
+set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_LIBRARIES=${LIBXML2_LIBRARIES}" CACHE STRING "" FORCE)
diff --git a/extensions/azure/CMakeLists.txt b/extensions/azure/CMakeLists.txt
index dffcf59..10bf4b5 100644
--- a/extensions/azure/CMakeLists.txt
+++ b/extensions/azure/CMakeLists.txt
@@ -37,7 +37,6 @@
target_include_directories(minifi-azure BEFORE PRIVATE ${CMAKE_SOURCE_DIR}/extensions/azure)
target_link_libraries(minifi-azure ${LIBMINIFI} Threads::Threads)
-target_link_libraries(minifi-azure LibXml2::LibXml2)
target_link_libraries(minifi-azure Azure::azure-storage-files-datalake Azure::azure-storage-blobs Azure::azure-storage-common Azure::azure-core Azure::azure-identity)
if (WIN32)
diff --git a/thirdparty/libxml2/libxml2-win.patch b/thirdparty/libxml2/libxml2-win.patch
deleted file mode 100644
index 67162bc..0000000
--- a/thirdparty/libxml2/libxml2-win.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-diff -rupN orig/CMakeLists.txt patched/CMakeLists.txt
---- orig/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ patched/CMakeLists.txt 2020-04-17 14:16:13.000000000 +0200
-@@ -0,0 +1,65 @@
-+cmake_minimum_required(VERSION 3.7)
-+
-+project(libxml2)
-+
-+set(SOURCES buf.c
-+ c14n.c
-+ catalog.c
-+ chvalid.c
-+ debugXML.c
-+ dict.c
-+ DOCBparser.c
-+ encoding.c
-+ entities.c
-+ error.c
-+ globals.c
-+ hash.c
-+ HTMLparser.c
-+ HTMLtree.c
-+ legacy.c
-+ list.c
-+ nanoftp.c
-+ nanohttp.c
-+ parser.c
-+ parserInternals.c
-+ pattern.c
-+ relaxng.c
-+ SAX.c
-+ SAX2.c
-+ schematron.c
-+ threads.c
-+ tree.c
-+ uri.c
-+ valid.c
-+ xinclude.c
-+ xlink.c
-+ xmlcatalog.c
-+ xmlIO.c
-+ xmlmemory.c
-+ xmlmodule.c
-+ xmlreader.c
-+ xmlregexp.c
-+ xmlsave.c
-+ xmlschemas.c
-+ xmlschemastypes.c
-+ xmlstring.c
-+ xmlunicode.c
-+ xmlwriter.c
-+ xpath.c
-+ xpointer.c)
-+
-+add_library(xml2 STATIC ${SOURCES})
-+
-+set_property(TARGET xml2 PROPERTY POSITION_INDEPENDENT_CODE ON)
-+
-+target_include_directories(xml2
-+ PRIVATE
-+ include
-+ win32/VC10)
-+
-+install(TARGETS xml2
-+ ARCHIVE DESTINATION lib
-+)
-+
-+install(DIRECTORY include/libxml DESTINATION include/libxml2
-+ FILES_MATCHING PATTERN "*.h")
-diff -rupN orig/include/libxml/xmlversion.h patched/include/libxml/xmlversion.h
---- orig/include/libxml/xmlversion.h 2019-10-30 20:14:29.000000000 +0100
-+++ patched/include/libxml/xmlversion.h 2020-04-17 14:52:58.000000000 +0200
-@@ -50,7 +50,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
- *
- * extra version information, used to show a CVS compilation
- */
--#define LIBXML_VERSION_EXTRA "-GITv2.9.10-rc1-2-ga5bb6aaa2"
-+#define LIBXML_VERSION_EXTRA ""
-
- /**
- * LIBXML_TEST_VERSION:
-@@ -171,7 +171,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
- *
- * Whether the FTP support is configured in
- */
--#if 1
-+#if 0
- #define LIBXML_FTP_ENABLED
- #endif
-
-@@ -180,7 +180,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
- *
- * Whether the HTTP support is configured in
- */
--#if 1
-+#if 0
- #define LIBXML_HTTP_ENABLED
- #endif
-
-@@ -270,7 +270,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
- *
- * Whether iconv support is available
- */
--#if 1
-+#if 0
- #define LIBXML_ICONV_ENABLED
- #endif
-
-@@ -395,7 +395,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
- *
- * Whether the Zlib support is compiled in
- */
--#if 1
-+#if 0
- #define LIBXML_ZLIB_ENABLED
- #endif
-
-@@ -404,7 +404,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
- *
- * Whether the Lzma support is compiled in
- */
--#if 1
-+#if 0
- #define LIBXML_LZMA_ENABLED
- #endif
-