Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

demidko/cmake-utility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

utility

A cross-platform C++20 command line tool template with dependency manager, powered by integration of CMake with Conan.

Usage

Make sure you are signed in to your GitHub account, then just click here to use template.

Motivation and goals

In the С++ world, now...

  • When an idea comes up, you have to create manually CMakeLists.txt, README.md, a directories structure, or finish the project created by the IDE to a portable state.
  • There is no dependency management without difficulties.
  • There is no cross-platform build without Qt.
  • These problems overlap, causing troubles for developers.

Therefore, utility is a template for creating and building cross-platform C++ projects with external dependencies. Utility is a tool like start.technology.io sites for Java, .NET and Rust.

Features and benefits

  • Full compatibility with existing technologies. No build configuration files are added except for the traditional CMakeLists.txt.
  • Created projects are supported in CLion, Visual Studio, VS Code IDEs.
  • Dockerfile of executable container and GitHub actions CI already exists by default.
  • Easy deploy to Digital Ocean.
  • Adding dependencies right in CMakeLists.txt only.
  • A project with all dependencies can be built on different OS without configuration changes.

Build

We need GCC or LLVM toolset, CMake build system and Conan libraries manager.

Prepare the project for building in release mode:

cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -B bin

Building together the application and tests:

cmake --build bin --target all

After that, the main self-executable utility will appear in the bin directory under the name app. The tests can be run by launching the test file located nearby.

Useful issues

Containerization

We need Docker installed:

docker build . -t utility

After that, we can run the utility in the container (if needed):

docker run -v `pwd`:`pwd` -w `pwd` -it --rm utility

To clean up docker use docker system prune -fa

Deploy

The sample configuration already exists in the .do directory. To deploy the application, just click the button.

Deploy to DigitalOcean

Conventions

  • The entry point must be located in the Main.cpp file for correct build script work.
  • To initialize resources, we using modern parameter passing by value, rather than a constant link.
  • Only the result of the compilation of * .cpp files in the src folder is included in the release assembly.
  • The src folder contains the *.cpp and *.h project files together.
  • The test folder contains the *.cpp and *.h project test files together.
  • Each *.h file must define only one entity in the global namespace, whose name must match the file name.
  • The contents of *.cpp files not declared in *.h file must be protected from external linkage from others compilation units by adding them to the anonymous namespace or adding the keyword static.

About

Modern C++ command line tool template

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages