Skip to content

wwhRyan/cmake-examples

This branch is up to date with ttroy50/cmake-examples:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Sep 14, 2021
2b27fc7 · Sep 14, 2021
Sep 14, 2021
Sep 14, 2021
Jan 18, 2020
Apr 23, 2020
Apr 24, 2020
Apr 15, 2018
Jan 18, 2020
Jan 18, 2020
Apr 4, 2019
Mar 18, 2018
Nov 21, 2015
Dec 17, 2019
Nov 21, 2015
May 5, 2019

Repository files navigation

CMake Examples

Introduction

CMake is a cross-platform open-source meta-build system which can build, test and package software. It can be used to support multiple native build environments including make, Apple’s xcode and Microsoft Visual Studio.

This repository includes some example modern CMake configurations which I have picked up when exploring it’s usage for various projects. The examples are laid out in a tutorial like format. The first examples are very basic and slowly increase in complexity drawing on previous examples to show more complex use cases.

These examples have been tested on Ubuntu 16.04 but should work under any Linux system that supports CMake v3.5+.

This branch works with the CMake version 3.5 onwards.

Build Status

Requirements

The basic requirements for most examples are:

  • CMake v3.5+

  • A c++ compiler (defaults to gcc)

  • make

Installation on Ubuntu

The easiest way to install the above on Ubuntu is as follows

$ sudo apt-get install build-essential
$ sudo apt-get install cmake

Some specific examples may require other tools including:

  • boost

    $ sudo apt-get install libboost-all-dev
  • protobuf

    $ sudo apt-get install libprotobuf-dev
    $ sudo apt-get install protobuf-compiler
  • cppcheck

    $ sudo apt-get install cppcheck
  • clang

    $ sudo apt-get install clang-3.6
  • ninja

    $ sudo apt-get install ninja-build
  • conan

    $ sudo apt-get install python3 python3-pip
    $ sudo pip3 install conan

Docker

Docker containers with all requirements and various versions of CMake are generated to help make testing the examples easier. These are available from the docker hub repository matrim/cmake-examples.

To build the full set of cmake-examples test cases you can run:

docker run -it matrim/cmake-examples:3.5.1
cd ~
git clone https://github.com/ttroy50/cmake-examples.git code
cd code
./test.sh

For more details on build and running the docker containers dockerfiles.

Other Links

There are many CMake tutorials and examples online. The list below includes links to some of these which I have found helpful in my CMake journey.

Packages

No packages published

Languages

  • CMake 48.1%
  • C++ 24.9%
  • Shell 11.0%
  • Python 8.4%
  • Roff 7.6%