[CMake] Module CheckIncludeFile should notify in case of flag errors

Claudio C claudio.caraffi at gmail.com
Wed Apr 20 08:37:40 EDT 2016


I recently struggled with the command CheckIncludeFile (and siblings) while
working with a custom toolchain.
Even if I was setting the necessary CMAKE_SYSROOT, include_directories and
even CMAKE_REQUIRED_INCLUDES, the commands would report a given header was
not found.

When I hacked into:
CheckIncludeFile.cmake
this line:
message(STATUS "OUTPUT=${OUTPUT}")
it turned out the problem was not in including file, but in the flags that
were passed to the compiler, causing a failure.

I think an error message should be printed instead in this case.
This could be handled in 2 ways:
a) Either checking first of all if, with the given flags, the compiler will
succeed in compiling a source file containing JUST an empty main function.
For efficiency, this check might even be done AFTER the first try_compile
fails.
b) Or, in case of failure, checking that the error returned is JUST the
cannot find error message.

What's your opinion about this? What would be the best option? Option a)
seems to have the advantage of being extremely easy to implement, although
might introduce some overhead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160420/d3aea1ee/attachment.html>


More information about the CMake mailing list