[cmake-developers] Fwd: Question about CHECK_C_COMPILER_FLAG

Brad King brad.king at kitware.com
Mon Jun 20 10:17:41 EDT 2016


On 06/20/2016 07:23 AM, Sergei Nikulov wrote:
> Documentation will tell that "the compiler does not give an error
> message when it encounters the flag".
> Unfortunately, it not only compiles but try to link executable.
> 
> If linker fails, due missed libraries it also does not produce
> positive result even if compilation was successful.
> 
> Is it expected behaviour or issue?

It is expected.  If a compiler cannot do "cc -flag hello.c" then
the flag must have some special behavior that needs a smarter check.

CMake 3.6 introduces CMAKE_TRY_COMPILE_TARGET_TYPE:

 https://cmake.org/cmake/help/v3.6/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html

which might be of help here.

-Brad



More information about the cmake-developers mailing list