Revert "[cmake] Add support for statically linking libxml2" (#191609)
Reverts llvm/llvm-project#166867
This commit is contained in:
@@ -172,10 +172,6 @@ set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
|
||||
set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
|
||||
|
||||
set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)
|
||||
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
|
||||
set_final_stage_var(LLVM_USE_STATIC_LIBXML2 "ON" BOOL)
|
||||
endif()
|
||||
|
||||
if (LLVM_RELEASE_ENABLE_LTO)
|
||||
set_final_stage_var(LLVM_ENABLE_FATLTO "ON" BOOL)
|
||||
set_final_stage_var(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/release_cpack_pre_build_strip_lto.cmake" STRING)
|
||||
|
||||
@@ -646,8 +646,6 @@ set(LLVM_TARGET_ARCH "host"
|
||||
|
||||
set(LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON, OFF, or FORCE_ON")
|
||||
|
||||
set(LLVM_USE_STATIC_LIBXML2 "OFF" CACHE BOOL "Use static version of libxml2. Can be ON, or OFF")
|
||||
|
||||
option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON)
|
||||
|
||||
option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON)
|
||||
|
||||
@@ -219,27 +219,14 @@ if(LLVM_ENABLE_LIBXML2)
|
||||
# Check if libxml2 we found is usable; for example, we may have found a 32-bit
|
||||
# library on a 64-bit system which would result in a link-time failure.
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBXML2_INCLUDE_DIR})
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBXML2_LIBRARY})
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBXML2_INCLUDE_DIRS})
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBXML2_LIBRARIES})
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LIBXML2_DEFINITIONS})
|
||||
check_symbol_exists(xmlReadMemory libxml/xmlreader.h HAVE_LIBXML2)
|
||||
cmake_pop_check_state()
|
||||
if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON AND NOT HAVE_LIBXML2)
|
||||
message(FATAL_ERROR "Failed to configure libxml2")
|
||||
endif()
|
||||
|
||||
if(LLVM_USE_STATIC_LIBXML2)
|
||||
if(NOT TARGET LibXml2::LibXml2Static)
|
||||
message(FATAL_ERROR "Failed to find static libxml2 library, but LLVM_USE_STATIC_LIBXML2=ON")
|
||||
endif()
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBXML2_INCLUDE_DIR})
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBXML2_STATIC_LIBRARY} ${LIBXML2_STATIC_DEPS})
|
||||
check_symbol_exists(xmlReadMemory libxml/xmlreader.h HAVE_LIBXML2_STATIC)
|
||||
cmake_pop_check_state()
|
||||
if(NOT HAVE_LIBXML2_STATIC)
|
||||
message(FATAL_ERROR "Failed to configure static libxml2, but LLVM_USE_STATIC_LIBXML2=ON")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(LLVM_ENABLE_LIBXML2 "${HAVE_LIBXML2}")
|
||||
endif()
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
# Try to find the libxml2 library
|
||||
#
|
||||
# If successful, the following variables will be defined:
|
||||
# LIBXML2_INCLUDE_DIR
|
||||
# LIBXML2_LIBRARY
|
||||
# LIBXML2_STATIC_LIBRARY
|
||||
# LibXml2_FOUND
|
||||
#
|
||||
# Additionally, the following import targets will be defined:
|
||||
# LibXml2::LibXml2
|
||||
# LibXml2::LibXml2Static (if the static library is found)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(PC_LIBXML QUIET libxml-2.0)
|
||||
endif()
|
||||
|
||||
find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
|
||||
HINTS
|
||||
${PC_LIBXML_INCLUDEDIR}
|
||||
${PC_LIBXML_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES libxml2
|
||||
)
|
||||
|
||||
if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
|
||||
set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
find_library(LIBXML2_LIBRARY NAMES xml2 libxml2 libxml2_a
|
||||
HINTS
|
||||
${PC_LIBXML_LIBDIR}
|
||||
${PC_LIBXML_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
find_library(LIBXML2_STATIC_LIBRARY NAMES
|
||||
"${CMAKE_STATIC_LIBRARY_PREFIX}xml2${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
"${CMAKE_STATIC_LIBRARY_PREFIX}libxml2${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
HINTS
|
||||
${PC_LIBXML_LIBDIR}
|
||||
${PC_LIBXML_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibXml2
|
||||
REQUIRED_VARS LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR
|
||||
VERSION_VAR PC_LIBXML_VERSION
|
||||
)
|
||||
|
||||
if(LibXml2_FOUND)
|
||||
if(NOT TARGET LibXml2::LibXml2)
|
||||
add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
|
||||
set_target_properties(LibXml2::LibXml2 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
|
||||
endif()
|
||||
if(LIBXML2_STATIC_LIBRARY AND NOT TARGET LibXml2::LibXml2Static)
|
||||
add_library(LibXml2::LibXml2Static STATIC IMPORTED)
|
||||
set_target_properties(LibXml2::LibXml2Static PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${LIBXML2_STATIC_LIBRARY}")
|
||||
# Static libraries need their transitive dependencies for linking.
|
||||
set(LIBXML2_STATIC_DEPS)
|
||||
foreach(lib IN LISTS PC_LIBXML_STATIC_LIBRARIES)
|
||||
if(NOT lib STREQUAL "xml2")
|
||||
list(APPEND LIBXML2_STATIC_DEPS ${lib})
|
||||
endif()
|
||||
endforeach()
|
||||
if(LIBXML2_STATIC_DEPS)
|
||||
set_target_properties(LibXml2::LibXml2Static PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${LIBXML2_STATIC_DEPS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY LIBXML2_STATIC_LIBRARY)
|
||||
@@ -1,11 +1,7 @@
|
||||
include(GetLibraryName)
|
||||
|
||||
if(LLVM_ENABLE_LIBXML2)
|
||||
if(LLVM_USE_STATIC_LIBXML2)
|
||||
set(imported_libs LibXml2::LibXml2Static)
|
||||
else()
|
||||
set(imported_libs LibXml2::LibXml2)
|
||||
endif()
|
||||
set(imported_libs LibXml2::LibXml2)
|
||||
endif()
|
||||
|
||||
add_llvm_component_library(LLVMWindowsManifest
|
||||
@@ -28,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2)
|
||||
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
|
||||
get_property(libxml2_library TARGET ${imported_libs} PROPERTY LOCATION_${build_type})
|
||||
get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type})
|
||||
endif()
|
||||
if(NOT libxml2_library)
|
||||
get_property(libxml2_library TARGET ${imported_libs} PROPERTY LOCATION)
|
||||
get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION)
|
||||
endif()
|
||||
get_library_name(${libxml2_library} libxml2_library)
|
||||
set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library})
|
||||
|
||||
Reference in New Issue
Block a user