[CMake] CMake command line arguments

Gabriel Petrovay gabipetrovay at gmail.com
Sun Mar 6 21:08:05 EST 2011


Hi,

I don't understand how to do that...

The user who builds does not set any environment and does not provide
any -D arguments. I want CMake to automatically configure variables
like: CMAKE_BUILD_TYPE or CMAKE_INSTALL_PREFIX when the user does not
provide them. So I want *my* default values. But I don't want to set
them when the user provides the *generator* ("NMake Makefiles")
default values.

The only way I see it is for CMake to tell you what parameters were
there in the command line. Does CMake support this?

How do you do this with the PATH environment variable?


Gabriel

On Mon, Mar 7, 2011 at 2:41 AM, 徐亮 <lxu4net at gmail.com> wrote:
>> From: Gabriel Petrovay <gabipetrovay at gmail.com>
>> Subject: [CMake] CMake command line arguments
>>
>> Hi,
>>
>> Is there a way to read the arguments that were passed to CMake from
>> inside a CMakeLists.txt file?
>>
>> There is a problem that some generators (like "NMake Makefiles") set a
>> default value for certain variables (like CMAKE_BUILD_TYPE=Debug,
>> CMAKE_INSTALL_PREFIX=C:\Program Files\${CMAKE_PROJECT_NAME})
>>
>> >From inside CMake one can not set up a different default value if the
>> user does not specify it with a -D option. This is because
>> IF(CMAKE_BUILD_TYPE) will always be true because of the default set by
>> the generator ("NMake Makefiles").
>>
>> There was this guy having the same problem:
>> http://www.mail-archive.com/cmake@cmake.org/msg09640.html
>>
>> Any solution how one can solve this? Reading the arguments passed to
>> CMake would be one, but I find no documentation/example/google_result
>> for this.
>>
>>
>> Thanks!
>>
>> --
>> MSc Gabriel Petrovay
>> Mobile: +41(0)787978034
>> www.28msec.com
>>
>
> I use "environment variables" to handle this problem. Such as “$ENV{PATH}”.
> Liang Xu
>
> _______________________________________________
> 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
>



-- 
MSc Gabriel Petrovay
Mobile: +41(0)787978034
www.28msec.com


More information about the CMake mailing list