title: CMake adds unnecessary dependencies between .o and .a files
body: <p>I've got a project managed by CMake with multiple libraries that have link time dependencies between them, but each of the libraries can be compiled independently of each other.  How do I express this to CMake so that I can build all the libraries concurrently?</p>
  
  <p>For example, I tried this CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.6)
  project (test)
  add_library(lib1 STATIC lib1.cpp)
  add_library(lib2 STATIC lib2.cpp)
  add_library(lib3 STATIC lib3.cpp)
  add_executable(main main.cpp)
  target_link_libraries(lib2 lib1)
  target_link_libraries(lib3 lib2)
  target_link_libraries(main lib3)
  </code></pre>
  
  <p>Each file just defines a different empty function like:</p>
  
  <pre><code>void f1() {}
  </code></pre>
  
  <p>When I type <code>cmake . &amp;&amp; make -j4</code>, I see this:</p>
  
  <pre><code>[ 25%] Building CXX object CMakeFiles/lib1.dir/lib1.cpp.o
  Linking CXX static library liblib1.a
  [ 25%] Built target lib1
  [ 50%] Building CXX object CMakeFiles/lib2.dir/lib2.cpp.o
  Linking CXX static library liblib2.a
  [ 50%] Built target lib2
  [ 75%] Building CXX object CMakeFiles/lib3.dir/lib3.cpp.o
  Linking CXX static library liblib3.a
  [ 75%] Built target lib3
  [100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
  Linking CXX executable main
  [100%] Built target main
  </code></pre>
  
  <p>Even though I've specified <code>-j4</code> and compiling each .cpp file should never depend on any .a files, it's waiting on the previous compile and link to finish begin the next one.  I'd rather see something like:</p>
  
  <pre><code>Building CXX object CMakeFiles/lib1.dir/lib1.cpp.o
  Building CXX object CMakeFiles/lib2.dir/lib2.cpp.o
  Building CXX object CMakeFiles/lib3.dir/lib3.cpp.o
  Building CXX object CMakeFiles/main.dir/main.cpp.o
  Linking CXX static library liblib1.a
  Built target lib1
  Linking CXX static library liblib2.a
  Built target lib2
  Linking CXX static library liblib3.a
  Built target lib3
  Linking CXX executable main
  Built target main
  </code></pre>
  
  <p>Is it possible to tell CMake that it can build all the .o files concurrently?</p>
  
  <p>In reality, I'm doing this in a million-line project with about 20 CPU cores at my disposal (with distcc), so this is a huge bottleneck on my build times.</p>