On Fri, Jul 29, 2011 at 2:47 AM, Eric Noulard <eric.noul...@gmail.com>wrote:
> 2011/7/29 J Decker <d3c...@gmail.com>: > > Any reason that environment variables can't be used as cmake > > variables? Like of course any cmake variable in a script would > > override the environment, but if it's not otherwise found, checking in > > the environemnt would make scripts prettier. > > > > > > set BUILD_TYPE=debug > > set BUILD_MONOLITHIC=1 > > cmake /path/to/source > > I think you could build this feature into your CMakeLists.txt already > did you try something like: > > if(NOT DEFINED BUILD_TYPE) > if("$ENV{BUILD_TYPE}" STRGREATER "") > message("BUILD_TYPE set from environment: $ENV{BUILD_TYPE}") > set(BUILD_TYPE $ENV{BUILD_TYPE}) > else() > message("BUILD_TYPE is not set") > endif() > else() > message("BUILD_TYPE is user defined: ${BUILD_TYPE}") > endif() > > beware that you may need to: > export BUILD_TYPE=Debug > and not > set BUILD_TYPE=Debug > Just as a courtesy FYI: # typically used on Linux/Mac/Unix and in .sh files (see your shell documentation if this doesn't work to set environment variables for you) export BUILD_TYPE=Debug @rem typically used in plain Windows cmd prompts, Visual Studio cmd prompts and .bat/.cmd files set BUILD_TYPE=Debug > because is forked by the shell and not a shell script, thus > it lose unexported var. > > It should even be doable to write a macro that would conditionnally > setup a list of varname from the environment if the CMake var is not > defined. > > If you do that send it here of put it on the Wiki, it may be useful for > others. > > > instead of having to pass -DBUILD_TYPE=debug -DBUILD_MONOLITHIC which > > gets strung out all on one line usually. some longer varaibles might > > be -DSACK_INTERSHELL_SDK_ROOT_PATH=$SACK_INTERSHELL_SDK_ROOT_PATH > > The good thing with the macro trick is that it would work for user > variable as well. > > -- > Erk > Membre de l'April - « promouvoir et défendre le logiciel libre » - > http://www.april.org > _______________________________________________ > cmake-developers mailing list > cmake-developers@cmake.org > http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers >
_______________________________________________ cmake-developers mailing list cmake-developers@cmake.org http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers