[cmake-developers] CMake generates Makefiles that don't parallelize as much as they could.

Brad King brad.king at kitware.com
Wed Jul 30 10:51:53 EDT 2014


On 07/30/2014 05:31 AM, Nick Overdijk wrote:
> https://github.com/NickNick/cmake-interface-includes/commits/master

Thanks.  For reference, the summary is:

 cmake_minimum_required(VERSION 2.8.12)
 project(FOO CXX)
 add_library(foo foo/foo.cpp)
 target_include_directories(foo INTERFACE foo)
 add_library(bar bar/bar.cpp)
 target_link_libraries(bar foo) # reduces parallel compilation
 #target_link_libraries(bar INTERFACE foo) # compiles bar without foo reqs

With CMake 3.0 you might be able to hack something up with INTERFACE
libraries, but that will increase complexity.

The INTERFACE workaround commented out in the above example is really
only good when no usage requirements need to be propagated.  Otherwise,
I think you're stuck with the reduced parallelism until CMake can be
taught to detect when it is safe to drop such dependencies as I
explained earlier.  FWIW, I've been building large projects this way
for years and rarely been bothered by this.  Usually each library has
so many sources that parallelism within each target is enough.

-Brad




More information about the cmake-developers mailing list