title: Appending to CMAKE_C_FLAGS
body: <p>I'm using CMake for a project that comes in two versions, one of which requires -lglapi and the other does not. </p>
  
  <p>So far the lines we used look like that: </p>
  
  <pre><code>SET(CMAKE_C_FLAGS "-O3 -xSSE3 -restrict -lpthread -lX11 -ldrm")
  SET(CMAKE_CXX_FLAGS "-O3 -xSSE3 -restrict -lpthread -lX11 -ldrm")
  </code></pre>
  
  <p>I added an if statement in my CMakeList.txt exactly after those lines: </p>
  
  <pre><code>if(SINGLE_MODE)
      SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} " -lglapi")
      SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} " -lglapi")
  endif(SINGLE_MODE)
  </code></pre>
  
  <p>The SINGLE_MODE variable is defined a little up. When I use the message command to display the content of the flag variables it looks alright:</p>
  
  <pre><code>-O3 -xSSE3 -restrict -lpthread -lX11 -ldrm -lglapi
  </code></pre>
  
  <p>But when I start compiling I am running into a compile error. Using the verbose mode I realized that in the compiler call it looks like that: </p>
  
  <pre><code>-O3 -xSSE3 -restrict -lpthread -lX11 -ldrm; -lglapi
  </code></pre>
  
  <p>I.e. somehow a semicolon got added before adding the -lglapi to the list. </p>
  
  <p>Did anyone here encounter a similar issue and knows a way to fix this issue? I've googled quite a while and studied the CMake manual but couldn't see what I did wrong here. </p>
  
  <p>Thanks,
  Tobias</p>