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 CXCompilationDatabase.cpp 15 CXLoadedDiagnostic.cpp 16 CXSourceLocation.cpp 17 CXStoredDiagnostic.cpp 18 CXString.cpp 19 CXType.cpp 20 IndexBody.cpp 21 IndexDecl.cpp 22 IndexTypeSourceInfo.cpp 23 Indexing.cpp 24 IndexingContext.cpp 25 26 ADDITIONAL_HEADERS 27 CIndexDiagnostic.h 28 CIndexer.h 29 CXCursor.h 30 CXLoadedDiagnostic.h 31 CXSourceLocation.h 32 CXString.h 33 CXTranslationUnit.h 34 CXType.h 35 Index_Internal.h 36 IndexingContext.h 37 ../../include/clang-c/Index.h 38 ) 39 40set(LIBS 41 clangAST 42 clangBasic 43 clangFrontend 44 clangIndex 45 clangLex 46 clangSema 47 clangTooling 48) 49 50if (CLANG_ENABLE_ARCMT) 51 list(APPEND LIBS clangARCMigrate) 52endif () 53 54find_library(DL_LIBRARY_PATH dl) 55if (DL_LIBRARY_PATH) 56 list(APPEND LIBS dl) 57endif() 58 59option(LIBCLANG_BUILD_STATIC 60 "Build libclang as a static library (in addition to a shared one)" OFF) 61 62set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.exports) 63 64if(MSVC) 65 # Avoid LNK4197 not to spceify libclang.def here. 66 # Each functions is exported as "dllexport" in include/clang-c. 67 # KB835326 68 set(LLVM_EXPORTED_SYMBOL_FILE) 69endif() 70 71if( LLVM_ENABLE_PIC ) 72 set(ENABLE_SHARED SHARED) 73endif() 74 75if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) 76 set(ENABLE_STATIC STATIC) 77endif() 78 79if(WIN32) 80 set(output_name "libclang") 81else() 82 set(output_name "clang") 83endif() 84 85add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} 86 OUTPUT_NAME ${output_name} 87 ${SOURCES} 88 DEPENDS clang-headers 89 90 LINK_LIBS 91 ${LIBS} 92 93 LINK_COMPONENTS 94 Core 95 Support 96 ) 97 98if(ENABLE_SHARED) 99 if(WIN32) 100 set_target_properties(libclang 101 PROPERTIES 102 VERSION ${LIBCLANG_LIBRARY_VERSION} 103 DEFINE_SYMBOL _CINDEX_LIB_) 104 else() 105 set_target_properties(libclang 106 PROPERTIES 107 VERSION ${LIBCLANG_LIBRARY_VERSION} 108 DEFINE_SYMBOL _CINDEX_LIB_) 109 endif() 110 111 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 112 set(LIBCLANG_LINK_FLAGS " -Wl,-compatibility_version -Wl,1") 113 if (DEFINED ${LLVM_SUBMIT_VERSION}) 114 set(LIBCLANG_LINK_FLAGS 115 "${LIBCLANG_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_SUBMIT_VERSION}.${LLVM_SUBMIT_SUBVERSION}") 116 endif() 117 118 set_property(TARGET libclang APPEND_STRING PROPERTY 119 LINK_FLAGS ${LIBCLANG_LINK_FLAGS}) 120 endif() 121endif() 122