Pass fetch_content_args to FetchContent_Declare for LibXml2 - #1853
Open
Manish7093 wants to merge 1 commit into
Open
Pass fetch_content_args to FetchContent_Declare for LibXml2#1853Manish7093 wants to merge 1 commit into
Manish7093 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fetch_content_argsincludesFIND_PACKAGE_ARGS, but it is never forwarded toFetchContent_Declare(), as a result, on CMake >= 3.24,find_package(LibXml2)is never attempted and the build always falls back to cloning libxml2 from git.This also breaks
FORCE_SYSTEM_LIBXML2, sinceCMAKE_REQUIRE_FIND_PACKAGE_LibXml2only takes effect whenFIND_PACKAGE_ARGSis passed toFetchContent_Declare().In offline build environments (e.g. distro build systems such as Fedora Koji, which
have no network and no git in the buildroot), configuration fails because CMake tries to clone libxml2 instead of using the installed system library.
CMake Error at /usr/share/cmake/Modules/ExternalProject/shared_internal_commands.cmake:928 (message): error: could not find git for clone of libxml2-populateNote:
${fetch_content_args}is appended as the last argument intentionally bcz everything after theFIND_PACKAGE_ARGSkeyword is forwarded tofind_package(), so it must come after the other options.With this change:
On CMake >= 3.24, the system libxml2 is preferred when available, with Git fallback otherwise.
FORCE_SYSTEM_LIBXML2correctly requires the system library.FORCE_BUILD_LIBXML2continues to always build from source.Checklist: