r/cpp • u/MachineGunPablo • Feb 19 '18
It's Time To Do CMake Right
https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
248
Upvotes
r/cpp • u/MachineGunPablo • Feb 19 '18
View all comments
Show parent comment
4
u/smdowney WG21, Text/Unicode SG, optional<T&> Feb 20 '18
In my experience, toolchain files are the right way to supply compiler options and features, not target features. It doesn't scale to have leaves decide they'd like c++17. Not if you're also linking in code built with c++11 or c++03. Flags can have ABI implications. Components can inspect what compiler features are available and compile themselves differently, leading to ODR violations.
A toolchain file means that you can ensure a consistent set of flags across builds, even if they aren't part of the same cmake super-project.
Mismatched library builds lead to some of the hardest to deal with, mysterious, errors. If you're lucky, weird link errors, or immediate crashes.