CMake build: wrong library order while building diagtool

Starting on a pristine directory, the build of ToT fails here with:

[1/32] Linking CXX executable bin/diagtool
FAILED: : && /home/oscar/bin/clang++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -Wno-nested-anon-types -O3 -DNDEBUG -Wl,--gc-sections tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/diagtool_main.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagTool.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ListWarnings.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ShowEnabledWarnings.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/TreeView.cpp.o -o bin/diagtool lib/libLLVMSupport.a lib/libclangBasic.a lib/libclangFrontend.a -lrt -ldl -ltinfo -lpthread -lz -Wl,-rpath,"\$ORIGIN/../lib" && :
lib/libclangBasic.a(SourceManager.cpp.o): In function `clang::SrcMgr::ContentCache::getBuffer(clang::DiagnosticsEngine&, clang::SourceManager const&, clang::SourceLocation, bool*) const':
/home/oscar/dev/llvm/llvm/tools/clang/lib/Basic/SourceManager.cpp:(.text._ZNK5clang6SrcMgr12ContentCache9getBufferERNS_17DiagnosticsEngineERKNS_13SourceManagerENS_14SourceLocationEPb+0x16f): undefined reference to `llvm::MemoryBuffer::getNewMemBuffer(unsigned long, llvm::StringRef)'

[hundreds of similar messages elided]

The problem is that libLLVMSupport is listed before libclangBasic on the
command. lib/Basic/CMakeLists.txt explicitly lists Support on its list
of dependencies, so the CMake scripts that determines the library order
are failing.

The question is: what's the problem and why this only happens here?

I'm using CMake 2.8.12.2 on Kubuntu 14.04 64 bits.

While running the cmake scripts multiple warnings likes this are
emitted:

CMake Warning (dev) in tools/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface. Run "cmake --help-policy CMP0022" for policy details. Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "clangDynamicASTMatchers" has an INTERFACE_LINK_LIBRARIES property.
  This should be preferred as the source of the link interface for this
  library but because CMP0022 is not set CMake is ignoring the property and
  using the link implementation as the link interface instead.

  INTERFACE_LINK_LIBRARIES:

    clangAST;clangASTMatchers;clangBasic;LLVMSupport

  Link implementation:

    (empty)

I see code at the beginning of clang/CMakeLists.txt and
llvm/CMakeLists.txt that should take care of the circumstance described
on the warning. Maybe the failed link is related to this?