Some nice and accurate CMake tips
bastian.rieck.me
bastian.rieck.me
I found it helpful to build a simple app composed of a few C++ files, headers and library dependencies and then write the bare minimum CMake script to build it. After that, I just keep iterating, adding CMake features, turning on or off C++ features, making it work on other platforms, compilers, bit-widths etc.
Now, I can't imagine starting a C++ project without using it.
This is the 'old' way of doing CMake -- the 'modern' transitive variants like target_include_directories and target_link_libraries have many advantages relative to the older usage.
$ mkdir build
$ cd build
$ cmake ../
$ cmake --build .
This has the advantage that it works for every generator on every platform, since cmake knows how to invoke the right command line build tool for the generator (make, ninja, msbuild, xcodebuild etc).
set_property(TARGET tgt PROPERTY CXX_STANDARD 11)
That way if you have multiple targets you're not setting it everywhere?