Check<Lang>SourceCompiles modules silently add a compiler definition
The CheckCSourceCompiles
, CheckCXXSourceCompiles
and CheckFortranSourceCompiles
modules silently add a compiler definition for the name of the output variable. For example, the following results in -DMY_OUT_VAR
being added to the compiler command line:
cmake_minimum_required(VERSION 3.8)
project(Example)
include(CheckCSourceCompiles)
check_c_source_compiles("int main() { return 0; }" MY_OUT_VAR)
It could be a reasonable thing to do, in which case it should be documented in case the variable name chosen could influence the test. Otherwise, unilaterally adding this compiler definition seems unnecessary since projects have the ability to add such a definition for themselves if they want it. Currently, the documentation makes no mention of this behaviour, so I recommend it either be documented (easier) or the extra compiler definition removed (could change the behaviour for existing projects).