Documentation of if(DEFINED) is missleading
I thinks the documentation of if(DEFINED) is missleading:
if(DEFINED <name>|CACHE{<name>}|ENV{<name>})
True if a variable, cache variable or environment variable with given
<name>
is defined. The value of the variable does not matter. Note that macro arguments are not variables.
I think it should me mentioned, that the first one is true when any variable type is set. One might think this tests only for "normal" variables. There is no way to check if the "normal" variable is set (hidden feature request here ;)).
Reproduction CMakeLists.txt:
$ rm CMakeCache.txt && cmake .
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- DEFINED_ANY: TRUE
-- DEFINED_CACHE: TRUE
-- DEFINED_ENV: TRUE
-- DEFINED_ANY: TRUE
-- DEFINED_CACHE: TRUE
-- DEFINED_ENV: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: D:/tmp/cmake_test