title: CMake command line for C++ #define
body: <p>I need to compile different versions of a certain project by adding compiler switches. Usually I would do this by using add_definitions or something like  </p>
  
  <pre><code>set_property( TARGET mylib PROPERTY COMPILE_DEFINITIONS _MYDEFINE=1 )
  </code></pre>
  
  <p>in the CMakeLists.txt file.</p>
  
  <p>In this specific project however, <strong>I am not allowed to modify any sources, including the CMakeLists.txt</strong> file.</p>
  
  <p>I was hoping that something like</p>
  
  <pre><code>cmake -D_MYDEFINE=1 &lt;path to sources&gt;
  </code></pre>
  
  <p>would generate a project file (Visual Studio 2008 in my case, but shouldn't matter) which includes _MYDEFINE=1 in its preprocessor definitions but in fact it won't.</p>
  
  <p>What are my options here? Is there a different cmake command line option to achieve this? Feel free to suggest solutions not including the command line, as long as changing the project's CMakeLists.txt is not necessary.</p>