[CMake] cmake -DX=Y -P : problem unsetting variables defined on command line

Sergey Zakharchenko doublef.mobile at gmail.com
Thu Feb 9 10:10:58 EST 2017


Hello list,

I've been using CMake for quite some time and have only now found out
this disturbing difference between SET(X) and SET(X ""). It happens in
cmake -P mode when you try to unset variables which are defined on the
command line, e.g.

cmake -DX=Y -P x.cmake

This x.cmake gives "X=Y":

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

This, too, gives "X=Y":

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

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

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

Is this OK? Is this documented anywhere?

Best regards,

-- 
DoubleF


More information about the CMake mailing list