[CMake] Idomatic cmake: Supporting gcc, icc, and clang with custom flags for each?
TCW
wafflecode at protonmail.com
Tue May 17 01:49:20 EDT 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160517/17853c9a/attachment-0001.html>
More information about the CMake
mailing list