[cmake-developers] Access output from CheckCXXSourceRuns and CheckCSourceRuns

Brad King brad.king at kitware.com
Tue Jan 19 10:42:18 EST 2016


On 01/18/2016 01:32 PM, Harry Mallon wrote:
> https://github.com/Kitware/CMake/pull/209
> This passes through the output of the run (as well as the return value)
> so that users can access any output without using try_run.

Thanks.  The signature of the macro takes a variable for the return value
to be stored.  We need something similar to control the name of the variable
used to store the output.  This could either be done with an optional/named
argument or simply by documenting that the output will come in `<var>_OUTPUT`.
We also need to define what happens when the check has already been run.
The normal `<var>` result is cached to prevent repeat runs of the check.
I don't think we can reasonably cache the entire output of the run and
provide it on later re-runs of CMake when the check does not actually run.

OTOH your use case for extracting versions may have other solutions.
We generally try to avoid try_run because it only works when the toolchain
targets the host architecture and so does not work when cross compiling
in general.  Look at what Modules/CMakeDetermineCompilerId.cmake does to
extract the compiler id and version information.  It also leaves files
in build trees under CMakeFiles/${CMAKE_VERSION}/CompilerIdC that you
can see.  Basically it encodes the needed information in strings that
can be extracted from the binaries without running them.

-Brad



More information about the cmake-developers mailing list