title: Use variable from CMAKE in C++
body: <p>I want to use a value declared in my CMakeLists.txt in my C++ code. I've tried to do like that :</p>
  
  <pre><code>ADD_DEFINITIONS( -D_MYVAR=1 )
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#if -D_MYVAR == 1
      #define var "someone"
  #else
      #define var "nobody"
  #endif
  int main(){
      std::cout &lt;&lt; "hello" &lt;&lt; var &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>But it doesn't work, and I don't understand why. Maybe I don't use ADD_DEFINITIONS correctly...</p>
  
  <p>Ideally, I wish do something like that :</p>
  
  <pre><code>ADD_DEFINITIONS( -D_MYVAR=\"someone\" )
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#define var D_MYVAR
  
  int main(){
      std::cout &lt;&lt; "hello" &lt;&lt; var &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>Is it possible ?</p>
  
  <p>Thanks !</p>