<div>Hello all,</div><div><br></div><div>On linux, what's the correct way to support building with several different C compilers, each with some extra compiler-specifc flags for Debug and Release modes?  (Eventually I'll need to add Visual Studio on Windows too. )<br></div><div><br></div><div>For now, I'm following what's mentioned in the cmake FAQ and using CXX=/blah cmake, etc. 
<br></div><div><br></div><div>(From: <a href="https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F">https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F</a>)
<br></div><div><br></div><div>But this is getting quite cumbersome as I'm experimenting with different flags for each compiler, and I'd rather avoid polluting my fairly clean CMakeLists file with a bunch of if/else branches to set flags.
<br></div><div><br></div><div>In the cmake manual I see reference to a -DCMAKE_TOOLCHAIN_FILE option, but this seems designed for embedded cross-compile scenarios.  (Is that right?)<br></div><div><br></div><div>(From: <a href="https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html">https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html</a>)
<br></div><div><br></div><div>Basically, I'd like to succinctly choose among a set of (slightly) customized compiler choices.<br></div><div><br></div><div>For modern cmake usage what is the correct method?  Can anybody point me to a well done example for a simple case like this?
<br></div><div><br></div><div>Thank you!
<br></div><div>tcw</div>