cmake/modules + x86_64
Brad King
brad.king at kitware.com
Mon Jan 30 20:40:57 CET 2006
Alexander Neundorf wrote:
> Brad could you please explain how the existing cache, -DSOME_VAR=whatever,
> set(SOME_VAR "value") and how the CACHE, FORCE and INTERNAL keywords for
> set() play together ? I.e. AFAIK I can't set a CMake variable which is not in
> the cache using cmake -D.
> What happens if I set a cmake variable which is in the cache in a
> CMakeLists.txt explicitely to some value ?
> Can I force a variable to go into the cache ?
There are two distinct sets of variables: listfile variables and cache
variables. The SET command changes listfile variables unless the CACHE
option is given in which case it changes cache variables AND the
listfile variables. When processing of CMakeLists.txt files begins the
listfile variables are initialized with the current values of the cache
variables.
Adding -DVAR=val on the command line defines an initial listfile
variable value. Adding -DVAR:TYPE=val on the command line defines a
cache variable value which is then included in the initalization of
listfile variables. In the first case the value is defined for that
session of cmake and lost afterwards. In the second case the value is
stored in the cache and will be used automatically on subsequent runs of
CMake.
The FORCE and INTERNAL keywords have to do with how cache values are
handled. The type of a cache value can be FILEPATH, PATH, STRING, BOOL,
or INTERNAL and is specified just after the CACHE option. The type
controls what kind of widget is used to present the cache value to the
user in the CMake GUI, and INTERNAL means to not present it at all.
Values of type INTERNAL are always set in by the SET command. Other
types of cache variables are set only if they are not already set or the
FORCE option is given. This allows users to edit the values in the GUI
without them being reset during the next CMake configure step.
> Why does this produce an error ?
> $ cat CMakeLists.txt
> set(SOME_VAR "hello" CACHE)
> $ cmake .
> CMake Error: Error in cmake code at
> /home/alex/src/tests/cmakeelse/CMakeLists.txt:1:
> SET Syntax error in SET:
> See the help for the SET command:
> SET (SOME_VARhelloCACHE)
From "cmake --help-command SET":
SET
Set a CMAKE variable to a given value.
SET(VAR [VALUE] [CACHE TYPE DOCSTRING [FORCE]])
if the CACHE option is used the type and docstring must also be specified.
-Brad
More information about the Kde-buildsystem
mailing list