commit 6d9fc46f2e4da600da26af6079ff0a2a7c371f63
Author: Michael Spencer <bigcheesegs@gmail.com>
Date:   Wed Sep 8 20:36:04 2010 -0400

    CMake: Update to use standard CMake dependency tracking facilities instead
    of whatever we were using before...

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ba2a62..fdc7755 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
 endif()
 
 # Compute the Clang version from the LLVM version.
-string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION 
+string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
   ${PACKAGE_VERSION})
 message(STATUS "Clang version: ${CLANG_VERSION}")
 
@@ -63,7 +63,7 @@ macro(add_clang_library name)
     set(srcs ${srcs} ${headers})
     string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
     list( GET split_path -1 dir)
-    file( GLOB_RECURSE headers 
+    file( GLOB_RECURSE headers
       ../../include/clang${dir}/*.h
       ../../include/clang${dir}/*.td
       ../../include/clang${dir}/*.def)
@@ -92,6 +92,9 @@ macro(add_clang_library name)
   if( llvm_system_libs )
     target_link_libraries(${name} ${llvm_system_libs})
   endif( llvm_system_libs )
+  if (LLVM_COMMON_LIBS)
+    target_link_libraries(${name} ${LLVM_COMMON_LIBS})
+  endif()
   add_dependencies(${name} ClangDiagnosticCommon)
   if(MSVC)
     get_target_property(cflag ${name} COMPILE_FLAGS)
@@ -102,6 +105,7 @@ macro(add_clang_library name)
     set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
   endif(MSVC)
   install(TARGETS ${name}
+    EXPORT LLVM
     LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
     ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
 endmacro(add_clang_library)
diff --git a/examples/PrintFunctionNames/CMakeLists.txt b/examples/PrintFunctionNames/CMakeLists.txt
index 5ea75db..1961fc3 100644
--- a/examples/PrintFunctionNames/CMakeLists.txt
+++ b/examples/PrintFunctionNames/CMakeLists.txt
@@ -3,6 +3,11 @@ set(MODULE TRUE)
 set(LLVM_NO_RTTI 1)
 
 add_clang_library(PrintFunctionNames PrintFunctionNames.cpp)
+target_link_libraries(PrintFunctionNames
+  clangAST
+  clangFrontend
+  clangBasic
+  )
 
 set_target_properties(PrintFunctionNames
   PROPERTIES
diff --git a/examples/clang-interpreter/CMakeLists.txt b/examples/clang-interpreter/CMakeLists.txt
index 73f28bb..776d2d2 100644
--- a/examples/clang-interpreter/CMakeLists.txt
+++ b/examples/clang-interpreter/CMakeLists.txt
@@ -1,34 +1,31 @@
 set(LLVM_NO_RTTI 1)
 
-set(LLVM_USED_LIBS
-    clangFrontend
-    clangSerialization
-    clangDriver
-    clangCodeGen
-    clangSema
-    clangChecker
-    clangIndex
-    clangAnalysis
-    clangRewrite
-    clangAST
-    clangParse
-    clangLex
-    clangBasic
-    )
-
-set(LLVM_LINK_COMPONENTS
-    jit
-    interpreter
-    nativecodegen
-    asmparser
-    bitreader
-    bitwriter
-    codegen
-    ipo
-    selectiondag
-  )
-
 add_clang_executable(clang-interpreter
   main.cpp
   )
+
+add_llvm_link_components(clang-interpreter jit interpreter nativecodegen)
+target_link_libraries(clang-interpreter
+  LLVMAsmParser
+  LLVMBitReader
+  LLVMBitWriter
+  LLVMCodeGen
+  LLVMipo
+  LLVMSelectionDAG
+
+  clangFrontend
+  clangSerialization
+  clangDriver
+  clangCodeGen
+  clangSema
+  clangChecker
+  clangIndex
+  clangAnalysis
+  clangRewrite
+  clangAST
+  clangParse
+  clangLex
+  clangBasic
+)
+
 add_dependencies(clang-interpreter clang-headers)
diff --git a/examples/wpa/CMakeLists.txt b/examples/wpa/CMakeLists.txt
index 13e4298..950dd2d 100644
--- a/examples/wpa/CMakeLists.txt
+++ b/examples/wpa/CMakeLists.txt
@@ -14,13 +14,10 @@ set(LLVM_USED_LIBS
   clangLex
   clangBasic)
 
-set( LLVM_LINK_COMPONENTS
-  bitreader
-  mc
-  core
-  )
-
 add_clang_executable(clang-wpa
   clang-wpa.cpp
   )
+
+target_link_libraries(clang-wpa LLVMBitReader LLVMMC LLVMCore)
+
 add_dependencies(clang-wpa clang-headers)
diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt
index 87bf834..0b386ff 100644
--- a/lib/Basic/CMakeLists.txt
+++ b/lib/Basic/CMakeLists.txt
@@ -14,6 +14,8 @@ add_clang_library(clangBasic
   Version.cpp
   )
 
+target_link_libraries(clangBasic LLVMMC)
+
 # Determine Subversion revision.
 # FIXME: This only gets updated when CMake is run, so this revision number
 # may be out-of-date!
@@ -24,7 +26,7 @@ if (Subversion_FOUND AND EXISTS "${CLANG_SOURCE_DIR}/.svn")
     PROPERTIES COMPILE_DEFINITIONS "SVN_REVISION=\"${CLANG_WC_REVISION}\"")
 endif()
 
-add_dependencies(clangBasic 
+add_dependencies(clangBasic
                  ClangARMNeon
                  ClangAttrList
                  ClangDiagnosticAnalysis
@@ -36,4 +38,4 @@ add_dependencies(clangBasic
                  ClangDiagnosticLex
                  ClangDiagnosticParse
                  ClangDiagnosticSema)
-                 
+
diff --git a/lib/CodeGen/CMakeLists.txt b/lib/CodeGen/CMakeLists.txt
index b5a2329..cd87506 100644
--- a/lib/CodeGen/CMakeLists.txt
+++ b/lib/CodeGen/CMakeLists.txt
@@ -37,5 +37,13 @@ add_clang_library(clangCodeGen
   TargetInfo.cpp
   )
 
+target_link_libraries(clangCodeGen
+  LLVMCore
+  LLVMAsmParser
+  LLVMBitReader
+  LLVMBitWriter
+  LLVMipo
+  )
+
 add_dependencies(clangCodeGen ClangAttrClasses ClangAttrList ClangDeclNodes
                  ClangStmtNodes)
diff --git a/lib/Frontend/CMakeLists.txt b/lib/Frontend/CMakeLists.txt
index 5a31495..c7e4472 100644
--- a/lib/Frontend/CMakeLists.txt
+++ b/lib/Frontend/CMakeLists.txt
@@ -27,6 +27,16 @@ add_clang_library(clangFrontend
   Warnings.cpp
   )
 
+target_link_libraries(clangFrontend
+  LLVMCore
+
+  clangParse
+  clangLex
+  clangSema
+  clangSerialization
+  clangDriver
+  )
+
 IF(MSVC)
   get_target_property(NON_ANSI_COMPILE_FLAGS clangFrontend COMPILE_FLAGS)
   string(REPLACE /Za
@@ -35,11 +45,12 @@ IF(MSVC)
   set_target_properties(clangFrontend PROPERTIES COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
 ENDIF(MSVC)
 
-add_dependencies(clangFrontend 
+add_dependencies(clangFrontend
   ClangAttrClasses
   ClangAttrList
-  ClangDiagnosticFrontend 
+  ClangDiagnosticFrontend
   ClangDiagnosticLex
   ClangDiagnosticSema
   ClangDeclNodes
-  ClangStmtNodes)
+  ClangStmtNodes
+  )
diff --git a/lib/Sema/CMakeLists.txt b/lib/Sema/CMakeLists.txt
index e65bb22..c8a580b 100644
--- a/lib/Sema/CMakeLists.txt
+++ b/lib/Sema/CMakeLists.txt
@@ -35,5 +35,7 @@ add_clang_library(clangSema
   TargetAttributesSema.cpp
   )
 
-add_dependencies(clangSema ClangARMNeon ClangAttrClasses ClangAttrList 
+target_link_libraries(clangSema clangAnalysis)
+
+add_dependencies(clangSema ClangARMNeon ClangAttrClasses ClangAttrList
                  ClangDiagnosticSema ClangDeclNodes ClangStmtNodes)
diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt
index 5cf2cd6..8ac37bb 100644
--- a/tools/c-index-test/CMakeLists.txt
+++ b/tools/c-index-test/CMakeLists.txt
@@ -1,6 +1,14 @@
 set(LLVM_NO_RTTI 1)
 
-set( LLVM_USED_LIBS
+add_clang_executable(c-index-test
+  c-index-test.c
+  )
+
+target_link_libraries(c-index-test
+  LLVMBitReader
+  LLVMMC
+  LLVMCore
+
   libclang
   clangIndex
   clangFrontend
@@ -14,16 +22,6 @@ set( LLVM_USED_LIBS
   clangBasic
   )
 
-set( LLVM_LINK_COMPONENTS
-  bitreader
-  mc
-  core
-  )
-
-add_clang_executable(c-index-test
-  c-index-test.c
-  )
-
 set_target_properties(c-index-test
   PROPERTIES
   LINKER_LANGUAGE CXX)
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
index ec6e9c6..8529700 100644
--- a/tools/driver/CMakeLists.txt
+++ b/tools/driver/CMakeLists.txt
@@ -1,6 +1,20 @@
 set(LLVM_NO_RTTI 1)
 
-set( LLVM_USED_LIBS
+add_clang_executable(clang
+  driver.cpp
+  cc1_main.cpp
+  cc1as_main.cpp
+  )
+
+add_llvm_link_components(clang all)
+target_link_libraries(clang
+  LLVMAsmParser
+  LLVMBitReader
+  LLVMBitWriter
+  LLVMCodeGen
+  LLVMipo
+  LLVMSelectionDAG
+
   clangFrontendTool
   clangFrontend
   clangDriver
@@ -17,22 +31,6 @@ set( LLVM_USED_LIBS
   clangBasic
   )
 
-set( LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  asmparser
-  bitreader
-  bitwriter
-  codegen
-  ipo
-  selectiondag
-  )
-
-add_clang_executable(clang
-  driver.cpp
-  cc1_main.cpp
-  cc1as_main.cpp
-  )
-
 if(UNIX)
   set(CLANGXX_LINK_OR_COPY create_symlink)
   set(CLANGXX_DESTDIR $ENV{DESTDIR}/)
diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
index 29ef574..e1dd0c5 100644
--- a/tools/libclang/CMakeLists.txt
+++ b/tools/libclang/CMakeLists.txt
@@ -2,23 +2,6 @@ set(SHARED_LIBRARY TRUE)
 
 set(LLVM_NO_RTTI 1)
 
-set(LLVM_USED_LIBS
-  clangFrontend
-  clangDriver
-  clangSerialization
-  clangParse
-  clangSema
-  clangAnalysis
-  clangAST
-  clangLex
-  clangBasic)
-
-set( LLVM_LINK_COMPONENTS
-  bitreader
-  mc
-  core
-  )
-
 add_clang_library(libclang
   CIndex.cpp
   CIndexCXX.cpp
@@ -30,19 +13,35 @@ add_clang_library(libclang
   CXCursor.cpp
   CXType.cpp
   ../../include/clang-c/Index.h
-)
+  )
+
+target_link_libraries(libclang
+  LLVMBitReader
+  LLVMMC
+  LLVMCore
+
+  clangFrontend
+  clangDriver
+  clangSerialization
+  clangParse
+  clangSema
+  clangAnalysis
+  clangAST
+  clangLex
+  clangBasic
+  )
 
 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   # dylib versioning information
   # FIXME: Is there a more CMake-ish way to handle this?
-  set(LIBCLANG_VERSION 1 
+  set(LIBCLANG_VERSION 1
       CACHE STRING "Version number of the libclang library")
   set(LIBCLANG_SUBVERSION 0
       CACHE STRING "Minor version number of the libclang library")
-  set(LIBCLANG_LINK_FLAGS 
+  set(LIBCLANG_LINK_FLAGS
       "-Wl,-current_version -Wl,${LIBCLANG_VERSION}.${LIBCLANG_SUBVERSION} -Wl,-compatibility_version -Wl,1")
 
-  set(LIBCLANG_LINK_FLAGS 
+  set(LIBCLANG_LINK_FLAGS
       "${LIBCLANG_LINK_FLAGS} -Wl,-dead_strip -Wl,-seg1addr -Wl,0xE0000000")
 
   set_target_properties(libclang
