On 02/09/2017 04:10 PM, Sergey Zakharchenko wrote:

cmake -DX=Y -P x.cmake

The above sets the *cache* variable X.

This x.cmake gives "X=Y":

SET(X)
MESSAGE("X=${X}")

The above unsets the *regular* variable X (leaving the cache variable X intact).

This, too, gives "X=Y":

UNSET(X)
MESSAGE("X=${X}")

This also unsets the *regular* variable X.
To unset the cache variable unset(X CACHE) would have worked.

This one finally gives "X=" (which I would have expected in the first place):

SET(X "")
MESSAGE("X=${X}")

Now you've got both a regular and cache variable named X.
When expanded the regular variable takes precedence.

Is this OK? Is this documented anywhere?

https://cmake.org/cmake/help/v3.7/manual/cmake-language.7.html#variables

Nils
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to