[cmake-developers] Using CMake to bootstrap clang builtins
Brad King
brad.king at kitware.com
Mon Nov 2 14:52:43 EST 2015
On 10/30/2015 03:05 PM, Chris Bieneman wrote:
> equivalent of try_compile that will test building a static archive
> instead of an executable?
For the "source file" signature of try_compile there is currently
no such option. The try_compile command also has a mode that builds
an entire source tree and of course then one could specify any type
of target because one writes the entire CMakeLists.txt file explicitly.
That doesn't help for the builtin checks and such though.
For the basic try_compile signature we hard-code add_executable here:
https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmCoreTryCompile.cxx;hb=v3.3.2#l477
We could consider an option to try_compile to ask it to use
add_library(... STATIC ...) instead of add_executable. However,
for your use case one needs this to work for the existing check
modules that CMake has, not just for your own try_compile calls.
IIUC in your case you have an already-built cross-compiler and are
running CMake on the project that provides the builtins. This
project uses some of CMake's compiler/platform check macros. We
need to make these checks work without running a linker because the
cross-compiler cannot link until the builtins are built.
Are you setting CMAKE_TOOLCHAIN_FILE for the build of the builtins?
What we need is for try_compile to learn to check for some global
option to be set by a toolchain or platform information module that
tells it there is no linker. Then try_compile could handle this
case by using add_library(... STATIC ...).
-Brad
More information about the cmake-developers
mailing list