]> granicus.if.org Git - clang/commitdiff
[CMake][Modules] libclang: Ignore _CINDEX_LIB_ and CLANG_TOOL_EXTRA_BUILD for -fmodules.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 31 Jul 2017 11:45:20 +0000 (11:45 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 31 Jul 2017 11:45:20 +0000 (11:45 +0000)
CLANG_TOOL_EXTRA_BUILD doesn't affect headers.

_CINDEX_LIB_ is defined when the target is SHARED.
On Win32, it affects clang-c/Platform.h and it shouldn't be ignored.

This is part of https://reviews.llvm.org/D35559

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309557 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CMakeLists.txt

index 2dd6703076360c1eba982068fd2fb4169820f17b..a28499c2c46963de80828119c881da0e463b46a6 100644 (file)
@@ -51,6 +51,9 @@ if (TARGET clangTidyPlugin)
   add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
   list(APPEND LIBS clangTidyPlugin)
   list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+    list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
 endif ()
 
 find_library(DL_LIBRARY_PATH dl)
@@ -115,6 +118,12 @@ if(ENABLE_SHARED)
       PROPERTIES
       VERSION ${LIBCLANG_LIBRARY_VERSION}
       DEFINE_SYMBOL _CINDEX_LIB_)
+    # FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
+    if(LLVM_ENABLE_MODULES AND NOT WIN32)
+      target_compile_options(libclang PRIVATE
+        "-fmodules-ignore-macro=_CINDEX_LIB_"
+        )
+    endif()
   endif()
 endif()