title: Why if(DEFINED <variable>) doesn't work in cmake?
body: <p>According to CMake documentation on <a href="https://cmake.org/cmake/help/v3.0/command/if.html" rel="noreferrer">if</a> keyword:</p>
  <blockquote>
  <p><code>if(DEFINED &lt;variable&gt;)</code></p>
  <p>True if the given variable is defined. It does not matter if the variable is true or false just if it has been set. (Note macro arguments are not variables.)</p>
  </blockquote>
  <p>I have this small CMakeLists.txt:</p>
  <pre><code>cmake_minimum_required(VERSION 2.6)
  project(abc)
  message(&quot;CMAKE_CXX_FLAGS_DEBUG 1: ${CMAKE_CXX_FLAGS_DEBUG}&quot;)
  if(DEFINED ${CMAKE_CXX_FLAGS_DEBUG})
  message(&quot;CMAKE_CXX_FLAGS_DEBUG 2: ${CMAKE_CXX_FLAGS_DEBUG}&quot;)
  endif(DEFINED ${CMAKE_CXX_FLAGS_DEBUG})
  message(&quot;CMAKE_CXX_FLAGS_DEBUG 3: ${CMAKE_CXX_FLAGS_DEBUG}&quot;)
  </code></pre>
  <p>which gives the next output on <code>cmake path/to/CMakeLists.txt</code> invocation:</p>
  <pre><code>CMAKE_CXX_FLAGS_DEBUG 1: -g
  CMAKE_CXX_FLAGS_DEBUG 3: -g
  -- Configuring done
  -- Generating done
  -- Build files have been written to: current/dir
  </code></pre>
  <p>Where is the second line?</p>
  <pre><code>CMAKE_CXX_FLAGS_DEBUG 2: -g
  </code></pre>