[CMake] Option dependencies

Jeroen Dierckx jeroen.dierckx at gmail.com
Fri Sep 11 11:28:20 EDT 2009


Hi,

We have a rather complex framework that we are converting to cmake. I
want to present the user with options to build some parts of our
framework or not. A lot of these options depend on others (when
building the Ogre rendering modules for example, our engine needs to
be built too).
I know I can use cmake_dependent_option, but this makes things too
confusing for the users (the ones building the framework I mean). In
that case, they first would have to enable building the engine before
they are presented with the option to build the Ogre targets, an
option which they can enable only then.

What I would want is that all these options are presented to the user,
but when they enable building the Ogre targets, the engine option is
automatically checked too. I can do this with the set function using
FORCE, but then I have to declare the whole variable again (with its
type and description). So what I would want is to force an existing
variable to ON, reflecting the change in the cmake GUI (so changing
the cached variable), but withouth having to declare it again.

Ideally I would be able to do the following:

if (NVE_BUILD_OGRE_TARGETS)
  # Force the existing cached variable to ON
  set (NVE_BUILD_ENGINE ON CACHE FORCE)
endif ()

I tried getting the description from an existing variable, but that
didn't work. I used the following code, which gave me a "NOT-FOUND":

get_property (DESC VARIABLE PROPERTY NVE_BUILD_ENGINE BRIEF_DOCS)

I also tried FULL_DOCS, without succes.

Greetings,
JeDi


More information about the CMake mailing list