[CMake] try_run understanding.

Alexander Neundorf a.neundorf-work at gmx.net
Sun Aug 22 16:09:19 EDT 2010


On Friday 20 August 2010, Ricardo Tiago wrote:
> Hi all,
>
> How can I use try_run with multiple source files?
>
> Something like: gcc  foo.c foo_fn.c -o newfoo
>
> So far I've came up with the following..
>
> try_run (RUN_RESULT_VAR COMPILE_RESULT_VAR
>             ${CMAKE_BINARY_DIR}
>             ${CMAKE_CURRENT_SOURCE_DIR}/foodir/foo.c
>             CMAKE_FLAGS
>              
> -DINCLUDE_DIRECTORIES:STRING=${CMAKE_CURRENT_SOURCE_DIR}/foodir/
> COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR)

try_run() and try_compile() are quite low level.
Did you have a look at the check_c/cxx_source_runs() macro coming with cmake ?
This is recommended in general.

Alex


More information about the CMake mailing list