Hello all,

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. )

For now, I'm following what's mentioned in the cmake FAQ and using CXX=/blah 
cmake, etc.

(From: https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F)

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.

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?)

(From: https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html)

Basically, I'd like to succinctly choose among a set of (slightly) customized 
compiler choices.

For modern cmake usage what is the correct method? Can anybody point me to a 
well done example for a simple case like this?

Thank you!
tcw
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to