[CMake] Proper options with cmake
Rolf Eike Beer
eike at sf-mail.de
Tue Jun 25 00:58:48 EDT 2013
Gennadiy Rozental wrote:
> Hi,
>
> How do I implement a proper option with default value. Both boolean and
> string.
>
> If I define option like this:
>
> option( GOO "descr" OFF )
>
> here is what happends:
>
> 1. First time I run cmake without specifying GOO, GOO is OFF
> 2. Any time I run cmake with -DGOO=ON, GOO is ON
> 3. Any time I run cmake with -DGOO=OFF, GOO is OFF
> 4. Any time after the first I run cmake without specifying GOO, GOO is the
> same as it was in previous run, not necessarily OFF.
>
> My problem is semantic of (4). What I want is for GOO to have default value
> I specified if one was not provided, regardless of what was the value of GOO
> in previous run. This seems like such an obvious expectation, that I do not
> understand why it is not the case now.
That is the sense of option(): provide a persistent choice.
What you want sounds like:
if(NOT DEFINED GOO)
set(GOO Off)
endif()
Eike
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130625/d9e2f619/attachment.pgp>
More information about the CMake
mailing list