diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 316ecc80d4..f9a60cbed3 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -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()