/cpp-project-templates

C++ CPP project templates with CMake + Conan

Primary LanguageC++

C++ CMake (+) Conan Project Templates

Overview

This project many C++ CMake and Conan project templates which can make easier for creating new projects instead of starting everything from scratch.

Project Templates Provided:

Basic CMake Projects:

Command Line Application with Subcommands akin to GIT (CLI11 Library)

  • CLI11 sample project
    • Directory: command-line-app-cli11
    • Description: Command line application with multiple subcommands akin to busybox or GIT (git commit, git log, git push, …)

OpenGL / Computer Graphics

  • Basic OpenGL Project

Boost Libraries / ASIO - Asynchrnous IO Framework

Pybind11

  • Python Pybind11 native module.
    • Directory: python-module-pybind11
    • Note a Python native module is a shared library - aka *.pyd (DLL) or *.so on Windows.

QT Cross Platform - Graphical User Interface Framework

  • Qt5 Widgets + Dynamically Loaded Form
    • Directory: qt5-qtwidgets-dynamically-loaded
    • Description: Sample project with Qt5 Widgets dynamically loaded. It doesn’t not use code generation from the form file, instead it loads the form file from the compiled resource at runtime. This approach is similar to use QML for describing the UI, but unlike QML, the control logic is entirely in C++.
  • Qt5 QtQuick QML

WX Widgets - Cross Platform GUI Toolkit Library

  • Wxwidgets
    • Directory: wxwidgets
    • Description: Sample CMake+Conan project with WxWidgets containing two targets, a sample application with multiple files and an application with a single file.
    • Note: WxWidget has a more permissive license than QT for static linking. However, it has a more scattered documentation and lacks good GUI designer such as QTCreator.

Usage:

Just copy the project template directory to a new location, open it in any IDE which supports CMake, namely, Clion, Visual Studio, QTCreator or KDevelop, and modify it.

Example:

  • 1 => Clone the repository:
$ mkdir -p /tmp/temp && cd /tmp/temp
$ git clone https://github.com/caiorss/cpp-project-templates
  • 2 => Copy the project template directory.
# Create my-opengll-project from template: 
$ cp -rv cpp-project-templates/basic-opengl-project my-opengl-project
'cpp-project-templates/basic-opengl-project' -> 'my-opengl-project'
'cpp-project-templates/basic-opengl-project/CMakeLists.txt' -> 'my-opengl-project/CMakeLists.txt'
'cpp-project-templates/basic-opengl-project/README.org' -> 'my-opengl-project/README.org'
'cpp-project-templates/basic-opengl-project/opengl1.cpp' -> 'my-opengl-project/opengl1.cpp'
  • 3 => Open the project with Visual Studio, QTCreator, CLion, KDevelop or any other supported IDE. Or generate the IDE-specific configuration files with CMake.
# Edit the new project with CMake
$ qtcreator my-opengl-project/CMakeLists.txt &
  • 3 => Or compile and build from command line.
 $ cd my-opengl1-project 

 $ cmake -H. -B_build -G Ninja -DCMAKE_BUILD_TYPE=Release

 $ cmake --build _build --target 
[2/2] Linking CXX executable openglDemo1.bin

# Run program: 
$ _build/openglDemo1.bin 

Repository

Dependencies configuration

Conan

Install Conan via PIP:

$ pip install --user conan

After the installation of Conan, add the following repositories:

$ conan remote add conan-center https://conan.bintray.com
$ conan remote add conan-community https://api.bintray.com/conan/conan-community/conan
$ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan

Dependency for Pybind11 (building Python Modules)

  • Note: Anaconda or Miniconda Python distributions already comes with Pythonb development headers or (SDK - Software Development Kit).
$ dnf install python3-devel 

Dependencies for OpenGL projects

Fedora Linux or Red-hat derivates:

$ dnf install -y freeglut-devel gl-manpages.noarch 

Dependencies for WXWidgets projects on Fedora Linux

$ dnf install -y gtk2-devel.x86_64
$ dnf install -y gtk+extra-devel.x86_64
$ dnf install -y SDL-devel.x86_64
$ dnf install -y SDL2-devel.x86_64
$ dnf install -y libXtst-devel.x86_64
$ dnf install -y libXt-devel.x86_6
$ dnf install -y compat-wxGTK3-gtk2.x86_64