[CMake] using TRY_COMPILE() for testing

Frank Stappers f.p.m.stappers at tue.nl
Sat Apr 10 03:26:40 EDT 2010


Hi,

I wanted to know if it whether it is possible to use TRY_COMPILE() in
a ADD_TEST(), such
that the results can be uploaded to a CDash server.
Currently, when executing cmake for the project all TRY_COMPILE()
statements are executed and
evaluated at configure time. This takes some time as there are roughly
600 TRY_COMPILES() executed,
which are project dependent.
So, I had the idea to do the following in a CMakeLists.txt:

add_test( foo  try_compile( result bindir foo.cpp ...  ) )

such that each of the test are executed when calling "ctest" Unfortunately,
this does not work, since "try_compile(...)" is not an executable. So my
guess is that I have to do something more advance.

So my question is what should be the "easiest" way to achieve this
kind of behavior?

KR,
Frank Stappers


More information about the CMake mailing list