GithubHelp home page GithubHelp logo

swachand / cmakeboilerplate Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 29 KB

Boilerplate for a cross-platform unit-tested C++ application using modern CMake

License: GNU General Public License v3.0

CMake 56.66% Shell 23.50% Batchfile 5.64% C++ 14.20%

cmakeboilerplate's Introduction

CMake Boilerplate

This boilerplate creates a unit-tested C++ application/library which uses CMake for cross-platform builds.

CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice - CMake

This boilerplate aims to keep things simple, use modern CMake features, and provide a good starting point for developers new to cmake.

Features

  • A C++ application/library that can be edited, built and tested on Windows/Linux
  • Uses powerful CMake functionality to minimise the use of platform specific code
  • Testing with Google Test/Mock.
  • Use of Docker for easy Linux debugging from a Windows environment.

Dependencies

  • C++ build tools
  • CMake 3.4.3 or newer
  • Git
  • Docker for Windows (optional)

Building

Command Line (Linux)

mkdir -p build-linux && cd "$_" && cmake .. && make

OR

./build-scripts/setup_build_linux.sh && cd build-linux && ./build_all.sh

IDE

Full CMake build support without a project file is supported in most common IDEs:

  • Visual Studio 2017 (Windows)
  • JetBrains CLion (Cross-platform)
  • QTCreator (Cross-platform)
  • Visual Studio Code (Cross-platform) with CMake Tools
  • See link for more

Running Tests

Using Generated Google Test Executables

Google test produces executables which cleanly indicate test results, so IDE integration is not essential. Simply run the generated test executable and you will see output as below: Google Test on Windows(left) and Linux (right)

Integrated Testing with IDEs

In-editor Google Test integration is not common at this stage, but it is available in

  • JetBrains CLion
  • QTCreator with this plugin
  • Visual Studio 2017 with ReSharper, although this functionality is not currently working for CMake projects in Visual Studio 2017 RC

Creating a Docker Container

The docker_build script create an Ubuntu 14.04 container with c++ build tools/CMake. The docker_start script mounts the project directory and sets it as the working directory.

Windows

cd docker
docker_build.bat
docker_start.bat

Linux

cd docker
./docker_build.sh
./docker_start.sh

Issues:

  • Not tested on Mac or any flavours of Linux aside from Ubuntu 14.04

cmakeboilerplate's People

Contributors

ldeakin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.