GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ttroy50/cmake-examples: Useful CMake Examples

BranchesTags
Open more actions menu

Latest commit

 

History

186 Commits
186 Commits

Folders and files

NameName
Last commit message
Last commit date
01-basic
01-basic
 
 
02-sub-projects
02-sub-projects
 
 
03-code-generation
03-code-generation
 
 
04-static-analysis
04-static-analysis
 
 
05-unit-testing
05-unit-testing
 
 
06-installer
06-installer
 
 
07-package-management
07-package-management
 
 
dockerfiles
dockerfiles
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.adoc
README.adoc
 
 
cmake-examples.sublime-project
cmake-examples.sublime-project
 
 
test.sh
test.sh
 
 

Repository files navigation

CMake Examples

Table of Contents
  • Introduction
  • Requirements
    • Installation on Ubuntu
    • Docker
  • Other Links

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.

  • For examples that use CMake version 2.x see the branch v2-style-includes.

  • For examples that use CMake version 3.0 see the branch v3.0-minimum

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.

  • Modern CMake Slides

  • rix0r Modern CMake Blog

  • Official CMake Tutorial

  • Official CMake Wiki

  • CMake Useful Variables

  • Derek Molloy - Intro to CMake

  • Modular C++ Projects

  • Common CMake Anti-Patterns

  • Using clang static analyser with CMake

  • Static Analysis with CDash - Includes some info about using CppCheck with CMake

  • CMake Tips

  • John Lamp - CMake Tutorial

  • Conan Documentation

About

Useful CMake Examples

ttroy50.github.io/cmake-examples

Topics

boostcatchclangclang-formatcmakecpackcppcppcheckctestgoogle-teststatic-analysistutorialunit-testing

Resources

Readme
MIT license
Activity

Stars

13.1k stars

Watchers

185 watching

Forks

2.5k forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.