A cross-platform C++20 command line tool template with dependency manager, powered by integration
of CMake
with Conan.
Make sure you are signed in to your GitHub account, then just
click here to use template.
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.
- 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 CodeIDEs. - 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.
We need CMake build system and Conan manager libraries.
Prepare the project for building in release mode:
cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -B binBuilding together the application and tests:
cmake --build bin --target allAfter 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.
We need Docker installed:
docker build . -t utilityAfter that, we can run the utility in the container (if needed):
docker run -it utilityThe sample configuration already exists in the .do directory. To deploy the application, just click the button.
- The entry point must be located in the
Main.cppfile 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
* .cppfiles in thesrcfolder is included in the release assembly. - The
srcfolder contains the*.cppand*.hproject files together. - The
testfolder contains the*.cppand*.hproject test files together. - Each
*.hfile must define only one entity in the global namespace, whose name must match the file name. - The contents of
*.cppfiles not declared in*.hfile must be protected fromexternal linkagefrom others compilation units by adding them to the anonymous namespace or adding the keywordstatic.