[CMake] Script Mode

David Cole david.cole at kitware.com
Thu May 13 15:13:01 EDT 2010


On Thu, May 13, 2010 at 3:04 PM, Alexander Neundorf <a.neundorf-work at gmx.net
> wrote:

> On Thursday 13 May 2010, Benoit Thomas wrote:
> > Hello,
> >
> > Is there any way to know if my code is running script mode (cmake -P) or
> > normal mode ? I wanna do something like this:
>
> For a specific case this should be possible.
> You should be able to check e.g. whether CMAKE_C_COMPILER (or CXX) is true.
> Or
> whether <YourProjectName>_SOURCE_DIR exists. Or CMAKE_SIZE_OF_VOIDP.
> Something like that should work.
>

Just be careful: those variables, while they are not normally set during a
script run, there is nothing that prevents them from being set in a script
context. So: it's a heuristic which will work 99.99% of the time... but
there will be that 1 in 10,000 case where somebody is doing something silly
like: including some cmake file that actually sets one of these variables.

But you should be able to find something work-able until issue #2828 is
actually addressed someday....

:-)
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100513/d03a3371/attachment.htm>


More information about the CMake mailing list