- Notifications
You must be signed in to change notification settings - Fork2.5k
ttroy50/cmake-examples
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
CMake is a cross-platform open-source meta-build system whichcan build, test and package software. It can be used to support multiple native build environments includingmake, Apple’s xcode and Microsoft Visual Studio.
This repository includes some example modern CMake configurations which I have picked upwhen 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 showmore 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.
For examples that use CMake version 2.x see the branchv2-style-includes.
For examples that use CMake version 3.0 see the branchv3.0-minimum
The basic requirements for most examples are:
CMake v3.5+
A c++ compiler (defaults to gcc)
make
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:
$ sudo apt-get install libboost-all-dev
$ sudo apt-get install libprotobuf-dev$ sudo apt-get install protobuf-compiler
$ sudo apt-get install cppcheck
$ sudo apt-get install clang-3.6
$ sudo apt-get install ninja-build
$ sudo apt-get install python3 python3-pip$ sudo pip3 install conan
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 repositorymatrim/cmake-examples.
To build the full set of cmake-examples test cases you can run:
docker run -it matrim/cmake-examples:3.5.1cd~git clone https://github.com/ttroy50/cmake-examples.git codecd code./test.sh
For more details on build and running the docker containersdockerfiles.
There are many CMake tutorials and examples online. The list below includes linksto some of these which I have found helpful in my CMake journey.
Static Analysis with CDash - Includes some info about using CppCheck with CMake