[CMake] Interrogate header files without TRY_RUN

David Gobbi david.gobbi at gmail.com
Thu Jun 16 12:26:08 EDT 2011


Hi All,

Is there a way for CMake to search for macro definitions in header
files without doing a try_run?  The reason I'm asking is that
eventually I'll require FindPython.cmake to report the version of
python that it finds.  But I don't want to do this by checking the
directory names (which is unreliable) or by doing a try_run (for the
sake of cross-compilation).  Running the python executable itself to
find the version is also out, due to cross-compilation.

For the VTK wrappers I've written a pseudo-preprocessor
(vtkWrapPreprocess.c) that does essentially what I need, but not at
configure time.  I'm thinking of the same thing for CMake... a simple
built-in preprocessor that can emulate a compiler and give cmake
access to macro definitions without the need for a try_run.  Or
equivalently the real compiler could run its preprocessor stage and
then present the results to cmake.  The main thing is to avoid the
try_run.

Any thoughts?

 - David


More information about the CMake mailing list