cmake - support find_package(CONFIG) for libxml2 dependency

This commit is contained in:
Andrej730
2025-09-04 16:11:31 +05:00
parent 8c12bd0322
commit f016d72787
+14 -2
View File
@@ -368,7 +368,19 @@ if(NOT MINIMAL_BUILD)
# libxml2 is required for IFCXML (optional) and SVGFILL (mandatory)
clear_wasm_sysroot()
if(IFCXML_SUPPORT)
find_package(LibXml2 REQUIRED)
if((NOT LIBXML2_INCLUDE_DIR AND NOT LIBXML2_LIBRARIES))
find_package(LibXml2 CONFIG REQUIRED)
message(STATUS "Found LibXml2 config: ${LibXml2_DIR}")
get_target_property(LIBXML2_INCLUDE_DIR LibXml2::LibXml2 INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(_libxml2_debug LibXml2::LibXml2 IMPORTED_LOCATION_DEBUG)
get_target_property(_libxml2_release LibXml2::LibXml2 IMPORTED_LOCATION_RELEASE)
set(LIBXML2_LIBRARIES
optimized ${_libxml2_release}
debug ${_libxml2_debug}
)
else()
find_package(LibXml2 REQUIRED)
endif()
endif()
restore_wasm_sysroot()
endif()
@@ -379,7 +391,7 @@ if(IFCXML_SUPPORT)
endif()
if(BUILD_IFCGEOM)
if(MSVC)
if(MSVC AND NOT LibXml2_DIR)
add_debug_variants(LIBXML2_LIBRARIES "${LIBXML2_LIBRARIES}" d)
endif()