ecbuild_check_c_source_return

Compile and run a given C source code and return its output.

ecbuild_check_c_source_return( <source>
                               VAR <name>
                               OUTPUT <name>
                               [ INCLUDES <path1> [ <path2> ... ] ]
                               [ LIBS <library1> [ <library2> ... ] ]
                               [ DEFINITIONS <definition1> [ <definition2> ... ] ] )

Options

VARrequired

name of the check and name of the CMake variable to write result to

OUTPUTrequired

name of CMake variable to write the output to

INCLUDESoptional

list of paths to add to include directories

LIBSoptional

list of libraries to link against (CMake targets or external libraries)

DEFINITIONSoptional

list of definitions to add to preprocessor defines

Usage

This will write the given source to a .c file and compile and run it with ecbuild_try_run. If successful, ${VAR} is set to 1 and ${OUTPUT} is set to the output of the successful run in the CMake cache.

The check will not run if ${VAR} is defined (e.g. from ecBuild cache).