wanener / cmake-examples

A collection of as simple as possible, modern CMake projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modern CMake Examples

Overview

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 🤦

Please see the Example README for steps on using the example libraries and the Installing README for an overview of installing CMake libraries.

Disclaimer

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.

Background

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.

For an explanation2 of what (in the context of CMake) installing is, please see the installing section and take a look at the various example projects for context.

  1. I recently discovered a kindred spirit on reddit
  2. My interpretation?

CMake Resources

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).

Articles

Documentation

Stack Overflow

YouTube

Books

Other

  • Cpplang Slack #cmake channel
    • There's some super helpful people on there, the search functionality is great too (someone likely will have had your problem before 😉).
  • vector-of-bool
    • Was incredibly kind in answering some of my dumb CMake questions - thank you!

About

A collection of as simple as possible, modern CMake projects

License:MIT License