title: CMake, multiple targets (asan tsan..) without having to recompile everything
body: <p><strong>Goal</strong>
  I want to define several targets:</p>
  
  <ul>
  <li>make msan: compiles the code with clang with memory sanitizer</li>
  <li>make tsan: compiles the code with clang with thread sanitizer</li>
  <li>make     : compiles the code with gcc</li>
  </ul>
  
  <p>And be able to easily switch between them.
  For example I don't want each time I switch rebuild all my objects, (I will have to do it the first time of course, but later if I modify a file and I do make and then make asan it should recompile only this file for each target)</p>
  
  <p><strong>What I have done so far</strong></p>
  
  <p>I have managed to create these targets and from the root directory, but each time I have to do a make clean and recompile.</p>
  
  <pre><code>option(CLANG_MSAN "Enable Clang memory sanitizer" OFF)
  if (CLANG_MSAN)
      set (CMAKE_CXX_FLAGS "-g -fsanitize=address -fno-omit-frame-pointer")
  endif()
  
  add_custom_target(asan
      COMMAND ${CMAKE_COMMAND}
      -DCLANG_MSAN=ON
      -DCMAKE_CXX_COMPILER=clang++
      -DCMAKE_C_COMPILER=clang)
  </code></pre>
  
  <p>Is it possible to do such a thing with CMake?</p>