Modern CMake Examples
This repository is a collection of as simple as possible CMake projects (with a focus on installing). The idea is to try and help understand exactly what each part of a
CMakeLists.txt file does and why it is needed.
This is basically intended as a series of reminders to help me remember how to use CMake 🤦
I am NOT a CMake expert - these examples may contain gaffs, faux pas, mistakes etc etc.. Please take everything with a pinch of salt and if you recognize a blatant error or mistake please feel free to create an issue or PR.
For the longest time I just didn't grok installing in CMake1.
I didn't understand why you'd ever want to do it, or what it was useful for. When I started looking into how to do it I could not make head nor tail of all the various install commands. While trying to figure all this stuff out I was immersing myself in trying to learn Modern CMake (targets, targets targets...) and how these two things are related.
The examples in this repo are the culmination of many months of sporadic research to try and understand CMake more fully and write better CMake scripts.
I'm sharing my journey so far to hopefully help some other poor soul who is in the same boat I'm in. With any luck there will be something someone finds useful here.
- I recently discovered a kindred spirit on reddit
- My interpretation?
I've been attempting to learn CMake for a while and have built up quite a list of articles/blogs/documentation that have helped inform my understanding up to this point. Please see them listed below (mainly for my benefit so I have them all in one place).
- The Coding Nest
- Pablo Arias
- GitLab.Kitware - CMake
- Arne Mertz
- Mario Badr
- Jetbrains - CLion
- SysProgs - visualgdb
- Cognitive Waves
- Reddit - How to CMake good
- Fosdem - Alexander Neundorf
- Daniel Pfeifer
- How to use CMake to find and link to a library using install-export and find_package?
- preferred cmake project structure
- CMake: How to set up source, library and CMakeLists.txt dependencies?
- CMake share library with multiple executables
- Setting CMAKE_INSTALL_PREFIX from CMakeLists.txt file
- Modern way to set compiler flags in cross-platform cmake project
- cmake usefulness of aliases
- Package vs Library
- After CMake install, I can't find a package with find_package
- cmake add_library, followed by install library destination
- CMake install is not installing libraries on Windows
- How to copy DLL files into the same folder as the executable using CMake?
- Path to target output file
- Building of executable and shared library with cmake, runtimelinker does not find dll
- A simple example of using cmake to build a Windows DLL
- C++Now 2017: Daniel Pfeifer “Effective CMake"
- CMake for Dummies
- C++Now 2018: Mateusz Pusz “Git, CMake, Conan: How to Ship and Reuse our C++ Projects”
- CppCon 2017: Mathieu Ropert “Using Modern CMake Patterns to Enforce a Good Modular Design”
- Embracing Modern CMake
- C++ Weekly - Ep 78 - Intro to CMake
- How to CMake Good - Recommended Order
- Professional CMake: A Practical Guide
- CMake Cookbook: Building, testing, and packaging modular software with modern CMake
- Mastering CMake (I haven't read this personally)