Index: cfe/trunk/CMakeLists.txt =================================================================== --- cfe/trunk/CMakeLists.txt +++ cfe/trunk/CMakeLists.txt @@ -323,6 +323,14 @@ set(CLANG_PYTHON_BINDINGS_VERSIONS "" CACHE STRING "Python versions to install libclang python bindings for") +set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL + "Link tools against libclang_shared.so") + +if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB) + message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when " + "LLVM_LINK_LLVM_DYLIB=OFF") +endif() + # The libdir suffix must exactly match whatever LLVM's configuration used. set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}") Index: cfe/trunk/cmake/modules/AddClang.cmake =================================================================== --- cfe/trunk/cmake/modules/AddClang.cmake +++ cfe/trunk/cmake/modules/AddClang.cmake @@ -172,3 +172,12 @@ # Always generate install targets llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) endmacro() + +function(clang_target_link_libraries target type) + if (CLANG_LINK_CLANG_DYLIB) + target_link_libraries(${target} ${type} clang_shared) + else() + target_link_libraries(${target} ${type} ${ARGN}) + endif() + +endfunction() Index: cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt =================================================================== --- cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt +++ cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt @@ -1,11 +1,13 @@ add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) - target_link_libraries(AnnotateFunctions PRIVATE + set(LLVM_LINK_COMPONENTS + Support + ) + clang_target_link_libraries(AnnotateFunctions PRIVATE clangAST clangBasic clangFrontend clangLex - LLVMSupport ) endif() Index: cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt =================================================================== --- cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt +++ cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt @@ -12,10 +12,12 @@ add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) - target_link_libraries(PrintFunctionNames PRIVATE + set(LLVM_LINK_COMPONENTS + Support + ) + clang_target_link_libraries(PrintFunctionNames PRIVATE clangAST clangBasic clangFrontend - LLVMSupport ) endif() Index: cfe/trunk/examples/clang-interpreter/CMakeLists.txt =================================================================== --- cfe/trunk/examples/clang-interpreter/CMakeLists.txt +++ cfe/trunk/examples/clang-interpreter/CMakeLists.txt @@ -19,7 +19,7 @@ clang-resource-headers ) -target_link_libraries(clang-interpreter +clang_target_link_libraries(clang-interpreter PRIVATE clangBasic clangCodeGen Index: cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt =================================================================== --- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt +++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt @@ -1,10 +1,13 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports) add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL clang) -target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE +clang_target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE clangAnalysis clangAST clangStaticAnalyzerCore clangStaticAnalyzerFrontend - LLVMSupport ) Index: cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt =================================================================== --- cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt +++ cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt @@ -1,10 +1,13 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports) add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE CheckerOptionHandling.cpp PLUGIN_TOOL clang) -target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE +clang_target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE clangAnalysis clangAST clangStaticAnalyzerCore clangStaticAnalyzerFrontend - LLVMSupport ) Index: cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt =================================================================== --- cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt +++ cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt @@ -1,10 +1,13 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports) add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL clang) -target_link_libraries(SampleAnalyzerPlugin PRIVATE +clang_target_link_libraries(SampleAnalyzerPlugin PRIVATE clangAnalysis clangAST clangStaticAnalyzerCore clangStaticAnalyzerFrontend - LLVMSupport ) Index: cfe/trunk/tools/arcmt-test/CMakeLists.txt =================================================================== --- cfe/trunk/tools/arcmt-test/CMakeLists.txt +++ cfe/trunk/tools/arcmt-test/CMakeLists.txt @@ -6,7 +6,7 @@ arcmt-test.cpp ) -target_link_libraries(arcmt-test +clang_target_link_libraries(arcmt-test PRIVATE clangARCMigrate clangBasic Index: cfe/trunk/tools/clang-check/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-check/CMakeLists.txt +++ cfe/trunk/tools/clang-check/CMakeLists.txt @@ -8,7 +8,7 @@ ClangCheck.cpp ) -target_link_libraries(clang-check +clang_target_link_libraries(clang-check PRIVATE clangAST clangBasic Index: cfe/trunk/tools/clang-diff/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-diff/CMakeLists.txt +++ cfe/trunk/tools/clang-diff/CMakeLists.txt @@ -6,7 +6,7 @@ ClangDiff.cpp ) -target_link_libraries(clang-diff +clang_target_link_libraries(clang-diff PRIVATE clangBasic clangFrontend Index: cfe/trunk/tools/clang-extdef-mapping/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-extdef-mapping/CMakeLists.txt +++ cfe/trunk/tools/clang-extdef-mapping/CMakeLists.txt @@ -7,7 +7,7 @@ ClangExtDefMapGen.cpp ) -target_link_libraries(clang-extdef-mapping +clang_target_link_libraries(clang-extdef-mapping PRIVATE clangAST clangBasic Index: cfe/trunk/tools/clang-format/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-format/CMakeLists.txt +++ cfe/trunk/tools/clang-format/CMakeLists.txt @@ -11,7 +11,7 @@ clangToolingCore ) -target_link_libraries(clang-format +clang_target_link_libraries(clang-format PRIVATE ${CLANG_FORMAT_LIB_DEPS} ) Index: cfe/trunk/tools/clang-import-test/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-import-test/CMakeLists.txt +++ cfe/trunk/tools/clang-import-test/CMakeLists.txt @@ -24,7 +24,7 @@ clangSerialization ) -target_link_libraries(clang-import-test +clang_target_link_libraries(clang-import-test PRIVATE ${CLANG_IMPORT_TEST_LIB_DEPS} ) Index: cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt +++ cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt @@ -17,7 +17,7 @@ add_dependencies(clang clang-offload-bundler) -target_link_libraries(clang-offload-bundler +clang_target_link_libraries(clang-offload-bundler PRIVATE ${CLANG_OFFLOAD_BUNDLER_LIB_DEPS} ) Index: cfe/trunk/tools/clang-refactor/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-refactor/CMakeLists.txt +++ cfe/trunk/tools/clang-refactor/CMakeLists.txt @@ -8,7 +8,7 @@ TestSupport.cpp ) -target_link_libraries(clang-refactor +clang_target_link_libraries(clang-refactor PRIVATE clangAST clangBasic Index: cfe/trunk/tools/clang-rename/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-rename/CMakeLists.txt +++ cfe/trunk/tools/clang-rename/CMakeLists.txt @@ -7,7 +7,7 @@ ClangRename.cpp ) -target_link_libraries(clang-rename +clang_target_link_libraries(clang-rename PRIVATE clangBasic clangFrontend Index: cfe/trunk/tools/clang-scan-deps/CMakeLists.txt =================================================================== --- cfe/trunk/tools/clang-scan-deps/CMakeLists.txt +++ cfe/trunk/tools/clang-scan-deps/CMakeLists.txt @@ -21,7 +21,7 @@ clangDependencyScanning ) -target_link_libraries(clang-scan-deps +clang_target_link_libraries(clang-scan-deps PRIVATE ${CLANG_SCAN_DEPS_LIB_DEPS} ) Index: cfe/trunk/tools/diagtool/CMakeLists.txt =================================================================== --- cfe/trunk/tools/diagtool/CMakeLists.txt +++ cfe/trunk/tools/diagtool/CMakeLists.txt @@ -12,7 +12,7 @@ TreeView.cpp ) -target_link_libraries(diagtool +clang_target_link_libraries(diagtool PRIVATE clangBasic clangFrontend Index: cfe/trunk/tools/driver/CMakeLists.txt =================================================================== --- cfe/trunk/tools/driver/CMakeLists.txt +++ cfe/trunk/tools/driver/CMakeLists.txt @@ -39,7 +39,7 @@ ${tablegen_deps} ) -target_link_libraries(clang +clang_target_link_libraries(clang PRIVATE clangBasic clangCodeGen Index: cfe/trunk/unittests/AST/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/AST/CMakeLists.txt +++ cfe/trunk/unittests/AST/CMakeLists.txt @@ -31,7 +31,7 @@ StructuralEquivalenceTest.cpp ) -target_link_libraries(ASTTests +clang_target_link_libraries(ASTTests PRIVATE clangAST clangASTMatchers Index: cfe/trunk/unittests/ASTMatchers/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/ASTMatchers/CMakeLists.txt +++ cfe/trunk/unittests/ASTMatchers/CMakeLists.txt @@ -18,7 +18,7 @@ ASTMatchersTraversalTest.cpp ) -target_link_libraries(ASTMatchersTests +clang_target_link_libraries(ASTMatchersTests PRIVATE clangAST clangASTMatchers Index: cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt +++ cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt @@ -8,7 +8,7 @@ RegistryTest.cpp ) -target_link_libraries(DynamicASTMatchersTests +clang_target_link_libraries(DynamicASTMatchersTests PRIVATE clangAST clangASTMatchers Index: cfe/trunk/unittests/Analysis/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Analysis/CMakeLists.txt +++ cfe/trunk/unittests/Analysis/CMakeLists.txt @@ -8,7 +8,7 @@ ExprMutationAnalyzerTest.cpp ) -target_link_libraries(ClangAnalysisTests +clang_target_link_libraries(ClangAnalysisTests PRIVATE clangAnalysis clangAST Index: cfe/trunk/unittests/Basic/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Basic/CMakeLists.txt +++ cfe/trunk/unittests/Basic/CMakeLists.txt @@ -10,7 +10,7 @@ SourceManagerTest.cpp ) -target_link_libraries(BasicTests +clang_target_link_libraries(BasicTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/CodeGen/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/CodeGen/CMakeLists.txt +++ cfe/trunk/unittests/CodeGen/CMakeLists.txt @@ -10,7 +10,7 @@ TBAAMetadataTest.cpp ) -target_link_libraries(ClangCodeGenTests +clang_target_link_libraries(ClangCodeGenTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/CrossTU/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/CrossTU/CMakeLists.txt +++ cfe/trunk/unittests/CrossTU/CMakeLists.txt @@ -7,7 +7,7 @@ CrossTranslationUnitTest.cpp ) -target_link_libraries(CrossTUTests +clang_target_link_libraries(CrossTUTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/Driver/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Driver/CMakeLists.txt +++ cfe/trunk/unittests/Driver/CMakeLists.txt @@ -11,7 +11,7 @@ MultilibTest.cpp ) -target_link_libraries(ClangDriverTests +clang_target_link_libraries(ClangDriverTests PRIVATE clangDriver clangBasic Index: cfe/trunk/unittests/Format/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Format/CMakeLists.txt +++ cfe/trunk/unittests/Format/CMakeLists.txt @@ -22,7 +22,7 @@ UsingDeclarationsSorterTest.cpp ) -target_link_libraries(FormatTests +clang_target_link_libraries(FormatTests PRIVATE clangBasic clangFormat Index: cfe/trunk/unittests/Frontend/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Frontend/CMakeLists.txt +++ cfe/trunk/unittests/Frontend/CMakeLists.txt @@ -12,7 +12,7 @@ PCHPreambleTest.cpp OutputStreamTest.cpp ) -target_link_libraries(FrontendTests +clang_target_link_libraries(FrontendTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/Index/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Index/CMakeLists.txt +++ cfe/trunk/unittests/Index/CMakeLists.txt @@ -7,7 +7,7 @@ IndexTests.cpp ) -target_link_libraries(IndexTests +clang_target_link_libraries(IndexTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/Lex/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Lex/CMakeLists.txt +++ cfe/trunk/unittests/Lex/CMakeLists.txt @@ -11,7 +11,7 @@ PPConditionalDirectiveRecordTest.cpp ) -target_link_libraries(LexTests +clang_target_link_libraries(LexTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/Rename/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Rename/CMakeLists.txt +++ cfe/trunk/unittests/Rename/CMakeLists.txt @@ -13,7 +13,7 @@ RenameFunctionTest.cpp ) -target_link_libraries(ClangRenameTests +clang_target_link_libraries(ClangRenameTests PRIVATE clangAST clangASTMatchers Index: cfe/trunk/unittests/Rewrite/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Rewrite/CMakeLists.txt +++ cfe/trunk/unittests/Rewrite/CMakeLists.txt @@ -5,7 +5,7 @@ add_clang_unittest(RewriteTests RewriteBufferTest.cpp ) -target_link_libraries(RewriteTests +clang_target_link_libraries(RewriteTests PRIVATE clangRewrite ) Index: cfe/trunk/unittests/Sema/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Sema/CMakeLists.txt +++ cfe/trunk/unittests/Sema/CMakeLists.txt @@ -7,7 +7,7 @@ CodeCompleteTest.cpp ) -target_link_libraries(SemaTests +clang_target_link_libraries(SemaTests PRIVATE clangAST clangBasic @@ -16,5 +16,9 @@ clangSema clangSerialization clangTooling - LLVMTestingSupport ) + +target_link_libraries(SemaTests + PRIVATE + LLVMTestingSupport +) Index: cfe/trunk/unittests/Serialization/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Serialization/CMakeLists.txt +++ cfe/trunk/unittests/Serialization/CMakeLists.txt @@ -8,7 +8,7 @@ InMemoryModuleCacheTest.cpp ) -target_link_libraries(SerializationTests +clang_target_link_libraries(SerializationTests PRIVATE clangAST clangBasic Index: cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt +++ cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt @@ -10,7 +10,7 @@ SymbolReaperTest.cpp ) -target_link_libraries(StaticAnalysisTests +clang_target_link_libraries(StaticAnalysisTests PRIVATE clangBasic clangAnalysis Index: cfe/trunk/unittests/Tooling/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Tooling/CMakeLists.txt +++ cfe/trunk/unittests/Tooling/CMakeLists.txt @@ -57,7 +57,7 @@ TransformerTest.cpp ) -target_link_libraries(ToolingTests +clang_target_link_libraries(ToolingTests PRIVATE clangAST clangASTMatchers @@ -71,8 +71,11 @@ clangToolingCore clangToolingInclusions clangToolingRefactoring - LLVMTestingSupport ) +target_link_libraries(ToolingTests + PRIVATE + LLVMTestingSupport +) add_subdirectory(Syntax) Index: cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt =================================================================== --- cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt +++ cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt @@ -6,7 +6,7 @@ TokensTest.cpp ) -target_link_libraries(SyntaxTests +clang_target_link_libraries(SyntaxTests PRIVATE clangAST clangBasic @@ -15,5 +15,9 @@ clangSerialization clangTooling clangToolingSyntax - LLVMTestingSupport ) + +target_link_libraries(SyntaxTests + PRIVATE + LLVMTestingSupport +)