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 option(LIBCLANG_BUILD_STATIC 41 "Build libclang as a static library (in addition to a shared one)" OFF) 42 43 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.exports) 44 45 if(MSVC) 46 # Avoid LNK4197 not to spceify libclang.def here. 47 # Each functions is exported as "dllexport" in include/clang-c. 48 # KB835326 49 set(LLVM_EXPORTED_SYMBOL_FILE) 50 endif() 51 52 if( LLVM_ENABLE_PIC ) 53 set(ENABLE_SHARED SHARED) 54 endif() 55 56 if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) 57 set(ENABLE_STATIC STATIC) 58 endif() 59 60 if(WIN32) 61 set(output_name "libclang") 62 else() 63 set(output_name "clang") 64 endif() 65 66 add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} 67 OUTPUT_NAME ${output_name} 68 ${SOURCES} 69 DEPENDS clang-headers 70 71 LINK_LIBS 72 clangARCMigrate 73 clangAST 74 clangBasic 75 clangFrontend 76 clangIndex 77 clangLex 78 clangSema 79 clangTooling 80 81 LINK_COMPONENTS 82 BitReader 83 Support 84 ) 85 86 if(ENABLE_SHARED) 87 if(WIN32) 88 set_target_properties(libclang 89 PROPERTIES 90 VERSION ${LIBCLANG_LIBRARY_VERSION} 91 DEFINE_SYMBOL _CINDEX_LIB_) 92 else() 93 set_target_properties(libclang 94 PROPERTIES 95 VERSION ${LIBCLANG_LIBRARY_VERSION} 96 DEFINE_SYMBOL _CINDEX_LIB_) 97 endif() 98 99 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 100 set(LIBCLANG_LINK_FLAGS " -Wl,-compatibility_version -Wl,1") 101 if (DEFINED ${LLVM_SUBMIT_VERSION}) 102 set(LIBCLANG_LINK_FLAGS 103 "${LIBCLANG_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_SUBMIT_VERSION}.${LLVM_SUBMIT_SUBVERSION}") 104 endif() 105 106 set_property(TARGET libclang APPEND_STRING PROPERTY 107 LINK_FLAGS ${LIBCLANG_LINK_FLAGS}) 108 endif() 109 endif() 110