mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[CMake] Simplify CMake handling for libxml2
This matches the changes made to handling of zlib done in 10b1b4a where we rely on find_package and the imported target rather than manually appending the library and include paths. The use of LLVM_LIBXML2_ENABLED has been replaced by LLVM_ENABLE_LIBXML2 thus reducing the number of variables. Differential Revision: https://reviews.llvm.org/D84563
This commit is contained in:
parent
513836d5fa
commit
04bcaa46b7
@ -137,6 +137,27 @@ if(LLVM_ENABLE_ZLIB)
|
|||||||
set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
|
set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LLVM_ENABLE_LIBXML2)
|
||||||
|
if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
|
||||||
|
find_package(LibXml2 REQUIRED)
|
||||||
|
elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
|
||||||
|
find_package(LibXml2)
|
||||||
|
endif()
|
||||||
|
if(LibXml2_FOUND)
|
||||||
|
# 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()
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${LIBXML2_INCLUDE_DIRS})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${LIBXML2_LIBRARIES})
|
||||||
|
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()
|
||||||
|
endif()
|
||||||
|
set(LLVM_ENABLE_LIBXML2 "${HAVE_LIBXML2}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Don't look for these libraries if we're using MSan, since uninstrumented third
|
# Don't look for these libraries if we're using MSan, since uninstrumented third
|
||||||
# party code may call MSan interceptors like strlen, leading to false positives.
|
# party code may call MSan interceptors like strlen, leading to false positives.
|
||||||
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
|
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
|
||||||
@ -161,21 +182,6 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
|
|||||||
else()
|
else()
|
||||||
set(LLVM_ENABLE_TERMINFO 0)
|
set(LLVM_ENABLE_TERMINFO 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
|
|
||||||
set(LLVM_LIBXML2_ENABLED 0)
|
|
||||||
set(LIBXML2_FOUND 0)
|
|
||||||
if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE))
|
|
||||||
find_package(LibXml2)
|
|
||||||
if (LIBXML2_FOUND)
|
|
||||||
set(LLVM_LIBXML2_ENABLED 1)
|
|
||||||
if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
|
|
||||||
include_directories(${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
|
|
||||||
else()
|
|
||||||
include_directories(${LIBXML2_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
set(LLVM_ENABLE_TERMINFO 0)
|
set(LLVM_ENABLE_TERMINFO 0)
|
||||||
endif()
|
endif()
|
||||||
@ -183,10 +189,6 @@ else()
|
|||||||
set(LLVM_ENABLE_TERMINFO 0)
|
set(LLVM_ENABLE_TERMINFO 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LLVM_ENABLE_LIBXML2 STREQUAL "FORCE_ON" AND NOT LLVM_LIBXML2_ENABLED)
|
|
||||||
message(FATAL_ERROR "Failed to congifure libxml2")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_library_exists(xar xar_open "" HAVE_LIBXAR)
|
check_library_exists(xar xar_open "" HAVE_LIBXAR)
|
||||||
if(HAVE_LIBXAR)
|
if(HAVE_LIBXAR)
|
||||||
set(XAR_LIB xar)
|
set(XAR_LIB xar)
|
||||||
|
17
cmake/modules/GetLibraryName.cmake
Normal file
17
cmake/modules/GetLibraryName.cmake
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Returns library name for a given path.
|
||||||
|
function(get_library_name path name)
|
||||||
|
get_filename_component(path ${path} NAME)
|
||||||
|
set(prefixes ${CMAKE_FIND_LIBRARY_PREFIXES})
|
||||||
|
set(suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
list(FILTER prefixes EXCLUDE REGEX "^\\s*$")
|
||||||
|
list(FILTER suffixes EXCLUDE REGEX "^\\s*$")
|
||||||
|
if(prefixes)
|
||||||
|
string(REPLACE ";" "|" prefixes "${prefixes}")
|
||||||
|
string(REGEX REPLACE "^(${prefixes})" "" path ${path})
|
||||||
|
endif()
|
||||||
|
if(suffixes)
|
||||||
|
string(REPLACE ";" "|" suffixes "${suffixes}")
|
||||||
|
string(REGEX REPLACE "(${suffixes})$" "" path ${path})
|
||||||
|
endif()
|
||||||
|
set(${name} "${path}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
@ -55,7 +55,10 @@ if(LLVM_ENABLE_ZLIB)
|
|||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LLVM_LIBXML2_ENABLED @LLVM_LIBXML2_ENABLED@)
|
set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@)
|
||||||
|
if(LLVM_ENABLE_LIBXML2)
|
||||||
|
find_package(LibXml2)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(LLVM_WITH_Z3 @LLVM_WITH_Z3@)
|
set(LLVM_WITH_Z3 @LLVM_WITH_Z3@)
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@
|
|||||||
#cmakedefine01 LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
|
#cmakedefine01 LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
|
||||||
|
|
||||||
/* Define if libxml2 is supported on this platform. */
|
/* Define if libxml2 is supported on this platform. */
|
||||||
#cmakedefine LLVM_LIBXML2_ENABLED ${LLVM_LIBXML2_ENABLED}
|
#cmakedefine LLVM_ENABLE_LIBXML2 ${LLVM_ENABLE_LIBXML2}
|
||||||
|
|
||||||
/* Define to the extension used for shared libraries, say, ".so". */
|
/* Define to the extension used for shared libraries, say, ".so". */
|
||||||
#cmakedefine LTDL_SHLIB_EXT "${LTDL_SHLIB_EXT}"
|
#cmakedefine LTDL_SHLIB_EXT "${LTDL_SHLIB_EXT}"
|
||||||
|
@ -1,24 +1,9 @@
|
|||||||
|
include(GetLibraryName)
|
||||||
|
|
||||||
if(LLVM_ENABLE_ZLIB)
|
if(LLVM_ENABLE_ZLIB)
|
||||||
set(imported_libs ZLIB::ZLIB)
|
set(imported_libs ZLIB::ZLIB)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(get_system_libname libpath libname)
|
|
||||||
get_filename_component(libpath ${libpath} NAME)
|
|
||||||
set(prefixes ${CMAKE_FIND_LIBRARY_PREFIXES})
|
|
||||||
set(suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
||||||
list(FILTER prefixes EXCLUDE REGEX "^\\s*$")
|
|
||||||
list(FILTER suffixes EXCLUDE REGEX "^\\s*$")
|
|
||||||
if( prefixes )
|
|
||||||
string(REPLACE ";" "|" prefixes "${prefixes}")
|
|
||||||
string(REGEX REPLACE "^(${prefixes})" "" libpath ${libpath})
|
|
||||||
endif()
|
|
||||||
if( suffixes )
|
|
||||||
string(REPLACE ";" "|" suffixes "${suffixes}")
|
|
||||||
string(REGEX REPLACE "(${suffixes})$" "" libpath ${libpath})
|
|
||||||
endif()
|
|
||||||
set(${libname} "${libpath}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if( MSVC OR MINGW )
|
if( MSVC OR MINGW )
|
||||||
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
|
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
|
||||||
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
|
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
|
||||||
@ -242,6 +227,8 @@ add_llvm_component_library(LLVMSupport
|
|||||||
|
|
||||||
set(llvm_system_libs ${system_libs})
|
set(llvm_system_libs ${system_libs})
|
||||||
|
|
||||||
|
# This block is only needed for llvm-config. When we deprecate llvm-config and
|
||||||
|
# move to using CMake export, this block can be removed.
|
||||||
if(LLVM_ENABLE_ZLIB)
|
if(LLVM_ENABLE_ZLIB)
|
||||||
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
|
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
|
||||||
if(CMAKE_BUILD_TYPE)
|
if(CMAKE_BUILD_TYPE)
|
||||||
@ -251,12 +238,12 @@ if(LLVM_ENABLE_ZLIB)
|
|||||||
if(NOT zlib_library)
|
if(NOT zlib_library)
|
||||||
get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
|
get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
|
||||||
endif()
|
endif()
|
||||||
get_system_libname(${zlib_library} zlib_library)
|
get_library_name(${zlib_library} zlib_library)
|
||||||
set(llvm_system_libs ${llvm_system_libs} "${zlib_library}")
|
set(llvm_system_libs ${llvm_system_libs} "${zlib_library}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LLVM_ENABLE_TERMINFO)
|
if(LLVM_ENABLE_TERMINFO)
|
||||||
get_system_libname(${TERMINFO_LIB} terminfo_library)
|
get_library_name(${TERMINFO_LIB} terminfo_library)
|
||||||
set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}")
|
set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,23 +1,28 @@
|
|||||||
|
include(GetLibraryName)
|
||||||
|
|
||||||
|
if(LLVM_ENABLE_LIBXML2)
|
||||||
|
set(imported_libs LibXml2::LibXml2)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_llvm_component_library(LLVMWindowsManifest
|
add_llvm_component_library(LLVMWindowsManifest
|
||||||
WindowsManifestMerger.cpp
|
WindowsManifestMerger.cpp
|
||||||
|
|
||||||
ADDITIONAL_HEADER_DIRS
|
ADDITIONAL_HEADER_DIRS
|
||||||
${LLVM_MAIN_INCLUDE_DIR}/llvm/WindowsManifest
|
${LLVM_MAIN_INCLUDE_DIR}/llvm/WindowsManifest
|
||||||
${Backtrace_INCLUDE_DIRS})
|
${Backtrace_INCLUDE_DIRS}
|
||||||
|
LINK_LIBS ${imported_libs})
|
||||||
|
|
||||||
if(LIBXML2_LIBRARIES)
|
# This block is only needed for llvm-config. When we deprecate llvm-config and
|
||||||
target_link_libraries(LLVMWindowsManifest PUBLIC ${LIBXML2_LIBRARIES})
|
# move to using CMake export, this block can be removed.
|
||||||
|
if(LLVM_ENABLE_LIBXML2)
|
||||||
get_filename_component(xml2_library ${LIBXML2_LIBRARIES} NAME)
|
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
|
||||||
if (CMAKE_STATIC_LIBRARY_PREFIX AND
|
if(CMAKE_BUILD_TYPE)
|
||||||
xml2_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
|
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
|
||||||
string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" xml2_library ${xml2_library})
|
get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type})
|
||||||
string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library})
|
|
||||||
elseif (CMAKE_SHARED_LIBRARY_PREFIX AND
|
|
||||||
xml2_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")
|
|
||||||
string(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" xml2_library ${xml2_library})
|
|
||||||
string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library})
|
|
||||||
endif()
|
endif()
|
||||||
set_property(TARGET LLVMWindowsManifest PROPERTY
|
if(NOT zlib_library)
|
||||||
LLVM_SYSTEM_LIBS ${xml2_library})
|
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})
|
||||||
endif()
|
endif()
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if LLVM_LIBXML2_ENABLED
|
#if LLVM_ENABLE_LIBXML2
|
||||||
#include <libxml/xmlreader.h>
|
#include <libxml/xmlreader.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static void errorCallback(void *Ctx, const char *Format, ...);
|
static void errorCallback(void *Ctx, const char *Format, ...);
|
||||||
Error getParseError();
|
Error getParseError();
|
||||||
#if LLVM_LIBXML2_ENABLED
|
#if LLVM_ENABLE_LIBXML2
|
||||||
xmlDocPtr CombinedDoc = nullptr;
|
xmlDocPtr CombinedDoc = nullptr;
|
||||||
std::vector<xmlDocPtr> MergedDocs;
|
std::vector<xmlDocPtr> MergedDocs;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ private:
|
|||||||
bool ParseErrorOccurred = false;
|
bool ParseErrorOccurred = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if LLVM_LIBXML2_ENABLED
|
#if LLVM_ENABLE_LIBXML2
|
||||||
|
|
||||||
static constexpr std::pair<StringLiteral, StringLiteral> MtNsHrefsPrefixes[] = {
|
static constexpr std::pair<StringLiteral, StringLiteral> MtNsHrefsPrefixes[] = {
|
||||||
{"urn:schemas-microsoft-com:asm.v1", "ms_asmv1"},
|
{"urn:schemas-microsoft-com:asm.v1", "ms_asmv1"},
|
||||||
|
@ -7,8 +7,8 @@ llvm_canonicalize_cmake_booleans(
|
|||||||
LLVM_ENABLE_FFI
|
LLVM_ENABLE_FFI
|
||||||
LLVM_ENABLE_THREADS
|
LLVM_ENABLE_THREADS
|
||||||
LLVM_ENABLE_ZLIB
|
LLVM_ENABLE_ZLIB
|
||||||
|
LLVM_ENABLE_LIBXML2
|
||||||
LLVM_INCLUDE_GO_TESTS
|
LLVM_INCLUDE_GO_TESTS
|
||||||
LLVM_LIBXML2_ENABLED
|
|
||||||
LLVM_LINK_LLVM_DYLIB
|
LLVM_LINK_LLVM_DYLIB
|
||||||
LLVM_TOOL_LTO_BUILD
|
LLVM_TOOL_LTO_BUILD
|
||||||
LLVM_USE_INTEL_JITEVENTS
|
LLVM_USE_INTEL_JITEVENTS
|
||||||
|
@ -356,7 +356,7 @@ if config.have_libxar:
|
|||||||
if config.enable_threads:
|
if config.enable_threads:
|
||||||
config.available_features.add('thread_support')
|
config.available_features.add('thread_support')
|
||||||
|
|
||||||
if config.llvm_libxml2_enabled:
|
if config.have_libxml2:
|
||||||
config.available_features.add('libxml2')
|
config.available_features.add('libxml2')
|
||||||
|
|
||||||
if config.have_opt_viewer_modules:
|
if config.have_opt_viewer_modules:
|
||||||
|
@ -35,13 +35,13 @@ config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
|
|||||||
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
|
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
|
||||||
config.have_zlib = @LLVM_ENABLE_ZLIB@
|
config.have_zlib = @LLVM_ENABLE_ZLIB@
|
||||||
config.have_libxar = @HAVE_LIBXAR@
|
config.have_libxar = @HAVE_LIBXAR@
|
||||||
|
config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
|
||||||
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
|
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
|
||||||
config.enable_ffi = @LLVM_ENABLE_FFI@
|
config.enable_ffi = @LLVM_ENABLE_FFI@
|
||||||
config.build_examples = @LLVM_BUILD_EXAMPLES@
|
config.build_examples = @LLVM_BUILD_EXAMPLES@
|
||||||
config.enable_threads = @LLVM_ENABLE_THREADS@
|
config.enable_threads = @LLVM_ENABLE_THREADS@
|
||||||
config.build_shared_libs = @BUILD_SHARED_LIBS@
|
config.build_shared_libs = @BUILD_SHARED_LIBS@
|
||||||
config.link_llvm_dylib = @LLVM_LINK_LLVM_DYLIB@
|
config.link_llvm_dylib = @LLVM_LINK_LLVM_DYLIB@
|
||||||
config.llvm_libxml2_enabled = @LLVM_LIBXML2_ENABLED@
|
|
||||||
config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
|
config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
|
||||||
config.host_arch = "@HOST_ARCH@"
|
config.host_arch = "@HOST_ARCH@"
|
||||||
config.have_opt_viewer_modules = @LLVM_HAVE_OPT_VIEWER_MODULES@
|
config.have_opt_viewer_modules = @LLVM_HAVE_OPT_VIEWER_MODULES@
|
||||||
|
@ -43,9 +43,9 @@ write_lit_cfg("lit_site_cfg") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxml2) {
|
if (llvm_enable_libxml2) {
|
||||||
extra_values += [ "LLVM_LIBXML2_ENABLED=1" ]
|
extra_values += [ "LLVM_ENABLE_LIBXML2=1" ]
|
||||||
} else {
|
} else {
|
||||||
extra_values += [ "LLVM_LIBXML2_ENABLED=0" ] # Must be 0.
|
extra_values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_zlib) {
|
if (llvm_enable_zlib) {
|
||||||
|
@ -304,9 +304,9 @@ write_cmake_config("config") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxml2) {
|
if (llvm_enable_libxml2) {
|
||||||
values += [ "LLVM_LIBXML2_ENABLED=1" ]
|
values += [ "LLVM_ENABLE_LIBXML2=1" ]
|
||||||
} else {
|
} else {
|
||||||
values += [ "LLVM_LIBXML2_ENABLED=" ]
|
values += [ "LLVM_ENABLE_LIBXML2=" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,9 +162,9 @@ write_lit_config("lit_site_cfg") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxml2) {
|
if (llvm_enable_libxml2) {
|
||||||
extra_values += [ "LLVM_LIBXML2_ENABLED=1" ]
|
extra_values += [ "LLVM_ENABLE_LIBXML2=1" ]
|
||||||
} else {
|
} else {
|
||||||
extra_values += [ "LLVM_LIBXML2_ENABLED=0" ] # Must be 0.
|
extra_values += [ "LLVM_ENABLE_LIBXML2=0" ] # Must be 0.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_threads) {
|
if (llvm_enable_threads) {
|
||||||
|
Loading…
Reference in New Issue
Block a user