• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1set(SOURCES
2  ARCMigrate.cpp
3  BuildSystem.cpp
4  CIndex.cpp
5  CIndexCXX.cpp
6  CIndexCodeCompletion.cpp
7  CIndexDiagnostic.cpp
8  CIndexHigh.cpp
9  CIndexInclusionStack.cpp
10  CIndexUSRs.cpp
11  CIndexer.cpp
12  CXComment.cpp
13  CXCursor.cpp
14  CXIndexDataConsumer.cpp
15  CXCompilationDatabase.cpp
16  CXLoadedDiagnostic.cpp
17  CXSourceLocation.cpp
18  CXStoredDiagnostic.cpp
19  CXString.cpp
20  CXType.cpp
21  Indexing.cpp
22
23  ADDITIONAL_HEADERS
24  CIndexDiagnostic.h
25  CIndexer.h
26  CXCursor.h
27  CXLoadedDiagnostic.h
28  CXSourceLocation.h
29  CXString.h
30  CXTranslationUnit.h
31  CXType.h
32  Index_Internal.h
33  ../../include/clang-c/Index.h
34  )
35
36set(LIBS
37  clangAST
38  clangBasic
39  clangFrontend
40  clangIndex
41  clangLex
42  clangSema
43  clangTooling
44)
45
46if (CLANG_ENABLE_ARCMT)
47  list(APPEND LIBS clangARCMigrate)
48endif ()
49
50if (TARGET clangTidyPlugin)
51  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
52  list(APPEND LIBS clangTidyPlugin)
53endif ()
54
55find_library(DL_LIBRARY_PATH dl)
56if (DL_LIBRARY_PATH)
57  list(APPEND LIBS dl)
58endif()
59
60option(LIBCLANG_BUILD_STATIC
61  "Build libclang as a static library (in addition to a shared one)" OFF)
62
63set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.exports)
64
65if(MSVC)
66  # Avoid LNK4197 not to spceify libclang.def here.
67  # Each functions is exported as "dllexport" in include/clang-c.
68  # KB835326
69  set(LLVM_EXPORTED_SYMBOL_FILE)
70endif()
71
72if( LLVM_ENABLE_PIC )
73  set(ENABLE_SHARED SHARED)
74endif()
75
76if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
77  set(ENABLE_STATIC STATIC)
78endif()
79
80if(WIN32)
81  set(output_name "libclang")
82else()
83  set(output_name "clang")
84endif()
85
86add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC}
87  OUTPUT_NAME ${output_name}
88  ${SOURCES}
89  DEPENDS clang-headers
90
91  LINK_LIBS
92  ${LIBS}
93
94  LINK_COMPONENTS
95  ${LLVM_TARGETS_TO_BUILD}
96  Core
97  Support
98  )
99
100if(ENABLE_SHARED)
101  if(WIN32)
102    set_target_properties(libclang
103      PROPERTIES
104      VERSION ${LIBCLANG_LIBRARY_VERSION}
105      DEFINE_SYMBOL _CINDEX_LIB_)
106  elseif(APPLE)
107    set(LIBCLANG_LINK_FLAGS " -Wl,-compatibility_version -Wl,1")
108    set(LIBCLANG_LINK_FLAGS "${LIBCLANG_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
109
110    set_property(TARGET libclang APPEND_STRING PROPERTY
111                 LINK_FLAGS ${LIBCLANG_LINK_FLAGS})
112  else()
113    set_target_properties(libclang
114      PROPERTIES
115      VERSION ${LIBCLANG_LIBRARY_VERSION}
116      DEFINE_SYMBOL _CINDEX_LIB_)
117  endif()
118endif()
119
120if(INTERNAL_INSTALL_PREFIX)
121  set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include")
122else()
123  set(LIBCLANG_HEADERS_INSTALL_DESTINATION include)
124endif()
125
126install(DIRECTORY ../../include/clang-c
127  COMPONENT libclang-headers
128  DESTINATION "${LIBCLANG_HEADERS_INSTALL_DESTINATION}"
129  FILES_MATCHING
130  PATTERN "*.h"
131  PATTERN ".svn" EXCLUDE
132  )
133
134if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
135  add_custom_target(install-libclang-headers
136    DEPENDS
137    COMMAND "${CMAKE_COMMAND}"
138            -DCMAKE_INSTALL_COMPONENT=libclang-headers
139            -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
140endif()
141