title: Modern way to set compiler flags in cross-platform cmake project
body: <p>I want to write a cmake file that sets different compiler options for clang++, g++ and MSVC in debug and release builds.
  What I'm doing currently looks something like this:</p>
  
  <pre><code>if(MSVC)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /W4")
      # Default debug flags are OK 
      set(CMAKE_CXX_FLAGS_RELEASE "{CMAKE_CXX_FLAGS_RELEASE} /O2")
  else()
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall -Wextra -Werror")
      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} some other flags")
      set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
  
      if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
      else()
          # nothing special for gcc at the moment
      endif()
  endif()
  </code></pre>
  
  <p>But I have a couple of problems with this:  </p>
  
  <ol>
  <li>First the trivial: Is there relly no command like appen that would allow me to replace <code>set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} Foo")</code> with <code>append(CMAKE_CXX_FLAGS "Foo")</code>?  </li>
  <li>I've read multiple times, that one should not manually set <code>CMAKE_CXX_FLAGS</code> and similar variables in the first place, but im not sure what other mechanism to use.</li>
  <li>Most importantly: The way I do it here, I need a separate build directory for each compiler and configuration Ideally I'd like to transform that into havin multiple targets in the same directory so I can e.g. call <code>make foo_debug_clang</code>.</li>
  </ol>
  
  <p><strong>So my questions are</strong>  </p>
  
  <ul>
  <li>a) Is there a better way to write th cmake script that solves my "pain points"?
  solution to the points mentioned above?</li>
  <li>b) Is there something like an accepted, modern best practice of how to set up such projects? </li>
  </ul>
  
  <p>Most references I could find on the internet are either out of date or show only trivial examples. I currently using cmake3.8, but if that makes any difference, I'm even more interested in the answer for more recent versions.</p>