1 set(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 40 set(LIBS 41 clangAST 42 clangBasic 43 clangFrontend 44 clangIndex 45 clangLex 46 clangSema 47 clangTooling 48 ) 49 50 if (CLANG_ENABLE_ARCMT) 51 list(APPEND LIBS clangARCMigrate) 52 endif () 53 54 find_library(DL_LIBRARY_PATH dl) 55 if (DL_LIBRARY_PATH) 56 list(APPEND LIBS dl) 57 endif() 58 59 option(LIBCLANG_BUILD_STATIC 60 "Build libclang as a static library (in addition to a shared one)" OFF) 61 62 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.exports) 63 64 if(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) 69 endif() 70 71 if( LLVM_ENABLE_PIC ) 72 set(ENABLE_SHARED SHARED) 73 endif() 74 75 if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) 76 set(ENABLE_STATIC STATIC) 77 endif() 78 79 if(WIN32) 80 set(output_name "libclang") 81 else() 82 set(output_name "clang") 83 endif() 84 85 add_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 ${LLVM_TARGETS_TO_BUILD} 95 Core 96 Support 97 ) 98 99 if(ENABLE_SHARED) 100 if(WIN32) 101 set_target_properties(libclang 102 PROPERTIES 103 VERSION ${LIBCLANG_LIBRARY_VERSION} 104 DEFINE_SYMBOL _CINDEX_LIB_) 105 elseif(APPLE) 106 set(LIBCLANG_LINK_FLAGS " -Wl,-compatibility_version -Wl,1") 107 set(LIBCLANG_LINK_FLAGS "${LIBCLANG_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}") 108 109 set_property(TARGET libclang APPEND_STRING PROPERTY 110 LINK_FLAGS ${LIBCLANG_LINK_FLAGS}) 111 else() 112 set_target_properties(libclang 113 PROPERTIES 114 VERSION ${LIBCLANG_LIBRARY_VERSION} 115 DEFINE_SYMBOL _CINDEX_LIB_) 116 endif() 117 endif() 118