[cmake-developers] [CMake] Toolchains and CMAKE_FORCE_C_COMPILER in 3.5
Brad King
brad.king at kitware.com
Wed Feb 24 11:08:24 EST 2016
On 02/17/2016 01:46 PM, James Crosby wrote:
>> Perhaps we could have a setting in a toolchain file like
[snip]
>> that tells CMake to use add_library(STATIC) instead of add_executable()
>> in its generated try_compile projects. That would avoid linking through
>> the toolchain.
>
> OK this makes a lot more sense to me now (I should have looked at the code
> first ;). It seems like the option to link a static library would have all the
> benefits of getting information out of the compiler itself (instead of
> duplicating it in toolchain files), without having to be able to produce a
> linkable executable.
Here is a change implementing this approach:
try_compile: Add option to control type of target
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f1bd9fe
One should be able to simply add
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
to the toolchain file. Then CMakeForceCompiler should not be needed anymore.
Please try it out.
Thanks,
-Brad
More information about the cmake-developers
mailing list