[cmake-developers] Supporting monolithic and efficient CMake + Ninja builds for LLVM developers

Stephen Kelly steveire at gmail.com
Thu Aug 6 01:38:20 EDT 2015


Chris Bieneman wrote:

> (resending now that I’ve subscribed to cmake-developers)
> 
> Hello CMake-Developers,
> 
> I’m a contributor to the LLVM project working on improving our CMake-based
> build process, and I had a request I wanted to discuss with your
> community.
> 
> This is related to a feature request I filed
> (http://public.kitware.com/Bug/view.php?id=15679
> <http://public.kitware.com/Bug/view.php?id=15679>), and one of the efforts
> I’ve been driving in the LLVM community
> (http://lists.llvm.org/pipermail/llvm-dev/2015-July/088751.html
> <http://lists.llvm.org/pipermail/llvm-dev/2015-July/088751.html>).
> 
> The complication for us is that because we’re building a compiler, and we
> can be targeting multiple operating systems and architectures within the
> same build, we want to be able to leverage CMake’s ability to detect the
> toolchain and target capabilities, which means invoking CMake multiple
> times.

What exactly do you mean by 'detect the toolchain and target capabilities'? 
What are the needs? Detecting things by running the compiler, or making use 
of the knowledge that is hardcoded into CMake Modules files?

> One of our common uses is building clang. When we build clang it is built
> with the ability to target a set of architectures. We then need to use the
> just-built clang to build the runtime libraries for each of the supported
> targets (which may not match the host operating system or architecture).

You might investigate doing something like

 # Don't let CMake use the c++ compiler for .cpp files in this directory
 unset(CMAKE_CXX_SOURCE_FILE_EXTENSIONS)

 set(CMAKE_CompilerRT_COMPILER $<TARGET_FILE:JustBuiltClang>)
 # Use the just built clang to build C++ files:
 set(CMAKE_CompilerRT_SOURCE_FILE_EXTENSIONS cpp)
 enable_language(CompilerRT)

 # Language is CompilerRT, not CXX, so JustBuiltClang is used
 add_library(compiler-rt compiler-rt.cpp)

and some other hacks maybe. Note that the above won't work currently because 
CMAKE_FOO_COMPILER does not support generator expressions. I also haven't 
tried it.

Thanks,

Steve.





More information about the cmake-developers mailing list