-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[cmake] Add support for statically linking libxml2 #166867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| include(ExternalProject) | ||
|
|
||
| if (NOT LIBXML2_PREFIX) | ||
| set (LIBXML2_PREFIX libxml2) | ||
| endif() | ||
|
|
||
| set(LIBXML2_PATH ${CMAKE_CURRENT_BINARY_DIR}/${LIBXML2_PREFIX}/src/${LIBXML2_PREFIX}) | ||
| set(LIBXML2_LIB_PATH ${LIBXML2_PATH}-build/libxml2.a) | ||
|
|
||
| ExternalProject_Add(${LIBXML2_PREFIX} | ||
| PREFIX ${LIBXML2_PREFIX} | ||
| GIT_REPOSITORY https://github.com/GNOME/libxml2.git | ||
| GIT_TAG v2.15.1 | ||
| CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
| -DBUILD_SHARED_LIBS=OFF | ||
| -DLIBXML2_WITH_PYTHON=OFF | ||
| -DLIBXML2_WITH_PROGRAMS=OFF | ||
| -DLIBXML2_WITH_TESTS=OFF | ||
| -DLIBXML2_WITH_LZMA=OFF | ||
| -DLIBXML2_WITH_ZLIB=OFF | ||
| CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} | ||
| -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} | ||
| -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON | ||
| BUILD_BYPRODUCTS ${LIBXML2_LIB_PATH} | ||
| UPDATE_COMMAND "" | ||
| INSTALL_COMMAND "" | ||
| ) | ||
|
Comment on lines
+10
to
+27
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want the build system to automatically clone and build a dependency without my approval (and what's worse, control this behavior by a flag such as |
||
|
|
||
| set(LIBXML2_INCLUDE_DIRS ${LIBXML2_PATH}/include ${LIBXML2_PATH}-build) | ||
| set(LIBXML2_LIBRARIES ${LIBXML2_LIB_PATH}) | ||
| set(LIBXML2_DEFINITIONS "") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of using the interface libraries (like
LibXml2::LibXml2) is to simplify our CMake code where we don't need to manually update the list include directories and link libraries and can instead depend on a single target, but this negates that benefit, even worse now we have to both depend on the interface target and manually update the list include directories and link libraries everywhere where we depend on libxml2.