[CMAKE] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

On MacOS, if CMAKE_OSX_SYSROOT is used and the user has command line tools
installed, we currently get the include path for libxml2 as
/usr/include/libxml2, instead of ${CMAKE_OSX_SYSROOT}/usr/include/libxml2.

Make it consistent on MacOS by prefixing ${CMAKE_OSX_SYSROOT} when
possible.

rdar://problem/41103601

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bruno Cardoso Lopes
2018-06-14 18:19:54 +00:00
parent d1d28702c6
commit 7d3355e402
+5 -1
View File
@@ -148,7 +148,11 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
find_package(LibXml2)
if (LIBXML2_FOUND)
set(LLVM_LIBXML2_ENABLED 1)
include_directories(${LIBXML2_INCLUDE_DIR})
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()
set(LIBXML2_LIBS "xml2")
endif()
endif()