We would like to conclude this discussion by pointing out some common pitfalls when moving to CMake.
- Global variables are code smell: This is true for any programming language, and CMake is no exception. Variables that are carried across CMake files, and in particular "upwards" from leaf to parent CMakeLists.txt files, indicate code smell. There is typically a better way to transfer dependencies. Ideally, dependencies should be imported through targets. Instead of assembling a list of libraries into a variable and carrying the variable across files, link to libraries one by one close to where they are defined. Instead of assembling source files into variables, add source files using target_sources. When linking to libraries ...