szaszm commented on a change in pull request #629:
URL: https://github.com/apache/nifi-minifi-cpp/pull/629#discussion_r415192181



##########
File path: cmake/BundledLibXml2.cmake
##########
@@ -0,0 +1,94 @@
+#
+# 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()
+
+    # 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
+        )
+    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-iconv=no --with-zlib=no --with-lzma=no 
--with-python=no --with-ftp=no --with-http=no 
--prefix=${BINARY_DIR}/thirdparty/libxml2-install

Review comment:
       Thanks for the explanation, I didn't know that this is common practice.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to