[CMake] How the heck does one set options?

Tim Gallagher tim.gallagher at gatech.edu
Wed Nov 2 22:15:03 EDT 2011


You're right, I left out the doc string part by mistake. You can see the correct usage in your trace. For instance:

option(gtest_force_shared_crt "Use shared (DLL) run-time lib even when Google Test is built as static lib." ON)

Tim

----- Original Message -----
From: "Steven Velez" <sbv1976 at gmail.com>
To: "Dan Kegel" <dank at kegel.com>
Cc: gtg085x at mail.gatech.edu, cmake at cmake.org
Sent: Wednesday, November 2, 2011 9:48:18 PM
Subject: Re: [CMake] How the heck does one set options?

Just a guess, but the docs for option state:

  option(<option_variable> "help string describing option"
         [initial value])

  Provide an option for the user to select as ON or OFF. If no initial
value is provided, OFF is used.

In this description is not optional, but the initial value is.  In the
usage presented, I believe "ON" may be interpreted as the doc string
and the default value is being taken?  Maybe Tim made a mistake in his
reply.

I don't know personally, I've never used this.

Steven


On Wed, Nov 2, 2011 at 9:36 PM, Dan Kegel <dank at kegel.com> wrote:
> On Wed, Nov 2, 2011 at 6:21 PM, Tim Gallagher <tim.gallagher at gatech.edu> wrote:
>> Using set() as you have done only sets the value in the current scoping unit. If you did:
>>
>> set(gtest_force_shared_crt ON CACHE INTERNAL "")
>>
>> then it will be set to ON and hidden from the GUI display.
>>
>> If it will always be a bool and you want it displayed on the GUI, you can also do:
>>
>> option(gtest_force_shared_crt ON)
>
> Tried it, no change, still broken.
>
> $ grep gtest_force_shared_crt CMakeLists.txt build/CMakeCache.txt
> CMakeLists.txt:option(gtest_force_shared_crt ON)
> build/CMakeCache.txt:gtest_force_shared_crt:BOOL=OFF
>
> --trace shows
>
> CMakeLists.txt(23):  option(gtest_force_shared_crt ON )
> gtest/CMakeLists.txt(14):  option(gtest_force_shared_crt Use shared
> (DLL) run-time lib even when Google Test is built as static lib. OFF )
>
> So, now what?  How does one set an option declared by a subdirectory
> before entering that subdirectory?  Lots of people use gtest, surely
> someone has run into this before.
> - Dan
> --
>
> 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