[CMake] How to list user-definable CMake variables

Kelly Thompson kgt at lanl.gov
Tue Sep 28 10:52:43 EDT 2010


Marcel,

We use a 'bootstrap' CMakeCache.txt file that has README-like full
documentation for each user settable variable.  This way a new developer can
copy the bootstrap CMakeCache.txt file to his/her build directory and edit
the file variable-by-variable before running cmake.

Something like:

# CMakeCache.txt - bootstrap file for new builds.

# Instructions.
# 1. Copy this file to your build directory as CMakeCache.txt.
# 2. Review and update all values in this file.
# 3. Environment must have $FC set to one of { ifort, gfortran or pathf90 }
# 4. From the build directory run 'cmake /full/path/to/source'

# Location where 'make install' will copy files to.
CMAKE_INSTALL_PREFIX:PATH=/full/path/to/target/directory

# CMAKE_BUILD_TYPE == { Release, Debug, RelWithDebInfo, MinSizeRel }
CMAKE_BUILD_TYPE:STRING=Release

# CMAKE_GENERATOR == { NMake Makefiles, Unix Makefiles, Visual Studio 9
2008, Visual Studio 9 2008 Win64 }
CMAKE_GENERATOR:STRING=Unix Makefiles

etc.

Maybe that is too clunky for you -- but has worked well for us.

-kt

> -----Original Message-----
> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
Of
> Eric Noulard
> Sent: Tuesday, September 28, 2010 3:12 AM
> To: Marcel Loose
> Cc: cmake at cmake.org; themiwi at gmail.com
> Subject: Re: [CMake] How to list user-definable CMake variables
> 
> 2010/9/28 Marcel Loose <loose at astron.nl>:
> >>
> >> You may want to call your target "help" but it would conflict/override
> >> the cmake builtin "help" target
> >> (at least for makefile generator) which display the list of available
> > target.
> >>
> >> This work AFTER cmake has been run. It could be run before as well
> > using:
> >>
> >> cmake -DCMAKE_MODULE_PATH=/path/to/source --help-module HelpMe
> >>
> >> but this is awkward :-(
> >>
> > Thanks Erk,
> >
> > I'll give it a thought. Your solution uses some nice CMake features, but
> > I find it a bit awkward. It suffers from separation of code and
> > documentation, though. That's always risky, since the two are likely to
> > diverge.
> 
> It is a little bit, but you can put in this "custom cmake file"
> (you may rename it to "CustomizableOptions.cmake")
> any CMake *code* you want including the definition of OPTION or vars
> (using SET) etc...
> 
> then in you CMakeLists.txt you can
> 
> include(CustomizableOptions.cmake)
> 
> and the "header" of the file contains the useful doc. for the
> concerned option/vars.
> 
> then the code and it's doc stay together.
> 
> 
> 
> 
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list