1 set(LLVM_LINK_COMPONENTS 2 ${LLVM_TARGETS_TO_BUILD} 3 asmparser 4 support 5 bitreader 6 mc 7 ) 8 9 set(SOURCES 10 ARCMigrate.cpp 11 CIndex.cpp 12 CIndexCXX.cpp 13 CIndexCodeCompletion.cpp 14 CIndexDiagnostic.cpp 15 CIndexDiagnostic.h 16 CIndexHigh.cpp 17 CIndexInclusionStack.cpp 18 CIndexUSRs.cpp 19 CIndexer.cpp 20 CIndexer.h 21 CXComment.cpp 22 CXCursor.cpp 23 CXCursor.h 24 CXCompilationDatabase.cpp 25 CXLoadedDiagnostic.cpp 26 CXLoadedDiagnostic.h 27 CXSourceLocation.cpp 28 CXSourceLocation.h 29 CXStoredDiagnostic.cpp 30 CXString.cpp 31 CXString.h 32 CXTranslationUnit.h 33 CXType.cpp 34 CXType.h 35 IndexBody.cpp 36 IndexDecl.cpp 37 IndexTypeSourceInfo.cpp 38 Index_Internal.h 39 Indexing.cpp 40 IndexingContext.cpp 41 IndexingContext.h 42 SimpleFormatContext.h 43 ../../include/clang-c/Index.h 44 ) 45 46 set(LIBRARIES 47 clangARCMigrate 48 clangRewriteCore 49 clangRewriteFrontend 50 clangFrontend 51 clangDriver 52 clangSerialization 53 clangSema 54 clangEdit 55 clangAST 56 clangLex 57 clangTooling 58 clangBasic 59 clangFormat 60 ) 61 62 set(GENERATED_HEADERS 63 ClangAttrClasses 64 ClangAttrList 65 ClangAttrParsedAttrList 66 ClangCommentNodes 67 ClangDiagnosticCommon 68 ClangDiagnosticFrontend 69 ClangDeclNodes 70 ClangStmtNodes 71 ) 72 73 if( LLVM_ENABLE_PIC ) 74 set(SHARED_LIBRARY TRUE) 75 add_clang_library(libclang ${SOURCES}) 76 target_link_libraries(libclang ${LIBRARIES}) 77 add_dependencies(libclang ${GENERATED_HEADERS} clang-headers) 78 79 if(WIN32) 80 set_target_properties(libclang 81 PROPERTIES 82 OUTPUT_NAME "libclang" 83 VERSION ${LIBCLANG_LIBRARY_VERSION} 84 DEFINE_SYMBOL _CINDEX_LIB_) 85 else() 86 set_target_properties(libclang 87 PROPERTIES 88 OUTPUT_NAME "clang" 89 VERSION ${LIBCLANG_LIBRARY_VERSION} 90 DEFINE_SYMBOL _CINDEX_LIB_) 91 endif() 92 93 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 94 set(LIBCLANG_LINK_FLAGS 95 "-Wl,-compatibility_version -Wl,1 -Wl,-dead_strip") 96 set_target_properties(libclang 97 PROPERTIES 98 LINK_FLAGS "${LIBCLANG_LINK_FLAGS}" 99 INSTALL_NAME_DIR "@executable_path/../lib") 100 endif() 101 102 103 set(LIBCLANG_STATIC_TARGET_NAME libclang_static) 104 else() 105 set(LIBCLANG_STATIC_TARGET_NAME libclang) 106 endif() 107 108 option(LIBCLANG_BUILD_STATIC 109 "Build libclang as a static library (in addition to a shared one)" OFF) 110 111 if( (NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32 ) 112 add_clang_library(${LIBCLANG_STATIC_TARGET_NAME} STATIC ${SOURCES}) 113 target_link_libraries(${LIBCLANG_STATIC_TARGET_NAME} ${LIBRARIES}) 114 add_dependencies(${LIBCLANG_STATIC_TARGET_NAME} ${GENERATED_HEADERS} clang-headers) 115 116 set_target_properties(${LIBCLANG_STATIC_TARGET_NAME} 117 PROPERTIES 118 OUTPUT_NAME "clang") 119 endif() 120