[CMake] Proper options with cmake

Gennadiy Rozental rogeeff at gmail.com
Mon Jun 24 19:37:02 EDT 2013


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.

Can I get what I want?





More information about the CMake mailing list