From db4a145be0328dcd18d92dc6f4b38235603bb7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6ck?= Date: Sat, 24 Jul 2021 09:54:21 +0200 Subject: [PATCH] [CMake] Add LIBXML2_DEFINITIONS when testing for symbol existance Currently when linking LLVM against Libxml2, a simple check is performed to check whether it can be linked successfully. This check currently adds the include directories and the libraries for libxml2, but not definitions found by the config. This causes issues on Windows when trying to link against a static libxml2. Libxml2 requires LIBXML_STATIC to be defined in the preprocessor to be able to link statically. This definition is put into LIBXML2_DEFINITIONS in the cmake config, but not properly forwarded to check_symbol_exists leading to it failing as it could not find xmlReadMemory in a DLL. This patch simply appends the content of LIBXML2_DEFINITIONS to the symbol check definitions, fixing the issue. Differential Revision: https://reviews.llvm.org/D106740 --- cmake/config-ix.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index d4cbf37d19a..dd0aaadb47c 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -149,6 +149,7 @@ if(LLVM_ENABLE_LIBXML2) cmake_push_check_state() 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)