[cmake-developers] I'm sure this is often asked
Eric Noulard
eric.noulard at gmail.com
Fri Jul 29 08:36:08 EDT 2011
2011/7/29 David Cole <david.cole at kitware.com>:
> On Fri, Jul 29, 2011 at 2:47 AM, Eric Noulard <eric.noulard at gmail.com>
> wrote:
>>
>> 2011/7/29 J Decker <d3ck0r at 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
Thanks David,
I always forgot how much I tend to ignore the Windows side of the world,
May be it's because I'd rather see the world from outside than from a
Window...
Just kidding off course :-]
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the cmake-developers
mailing list