[CMake] configuration input to cmake

Jun Sun jsun at junsun.net
Mon May 14 13:34:42 EDT 2007


Thanks for the pointers. It makes a lot of sense to me.

Jun

On Sat, May 12, 2007 at 10:09:15AM +0200, Eric Noulard wrote:
> 2007/5/12, Jun Sun <jsun at junsun.net>:
> >On Fri, May 11, 2007 at 01:38:26PM -0400, Bill Hoffman wrote:
> >> Guilherme Balena Versiani wrote:
> >> >
> >> >
> >> >Jun Sun escreveu:
> >> >>My build process involves a configuration stage. It roughly looks like
> >> >>this:
> >> >>
> >> >>* Generate cmakefile.inc and config.h from .config file
> >> You may also want to look at the configure_file command.
> >>
> >
> >Interesting -
> >
> >So I could just define the all config variables in cmakefile.inc
> 
> You may eventually get rid of your cmakefile.inc
> if you use OPTION command in your root CMakeLists.txt.
> Or if you have "typical" config conf1/conf2/conf3 you may
> create
> 
> conf1.cmake
> conf2.cmake
> conf3.cmake
> 
> and optionnally include either file depending on a CMake variable value
> passed on the command line/ccmake:
> 
> cmake -DOPTCONF:STRING="conf1"
> 
> or triggered by a Cmake OPTION command:
> 
> In your CMakeLists.txt:
> ----
> OPTION(BUILD_CONF1 "Build with CONF1 profile" OFF)
> IF (BUILD_CONF1)
>    INCLUDE(conf1.cmake)
> ENDIF(BUILD_CONF1)
> ----
> 
> then on the command line:
> 
> cmake -DBUILD_CONF1=ON
> 
> >and then use cmake to generate the config.h file, looks like.
> 
> Yes, as noted by Bill,
> CONFIGURE_FILE is able to generate such file.
> 
> you may have a look at this Wiki item too:
> http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks
> 
> 
> -- 
> Erk


More information about the CMake mailing list