A cross-platform C++20
command line tool template with dependency manager, powered by integration
of cmake
with vcpkg
.
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, vcpkg-utility
is a template for creating and building cross-platform C++ projects with external
dependencies. vcpkg-utility
is a tool like start.your-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 Code
IDEs. - Adding dependencies is done with one command through integration with
vcpkg
. - A project with all dependencies can be built on different OS without configuration changes.
We need cmake
build system and vcpkg
manager
libraries. It's easy to install with system package manager, brew
for example.
- Install the dependencies:
vcpkg install
catch2
cli11
fmt
(If you are using an IDE, you can stop at this step simply by settingCMake options
as the result ofvcpkg integrate install
command) - Prepare the directory for building using the dependencies
vcpkg
:
cmake `vcpkg integrate install | tail -1 | cut -d \" -f2` -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -B cmake-build-release
On Windows, instead of the code in``
quotes, manually substitute the parameter obtained by callingvcpkg integrate install
. - Putting together the directory and tests:
cmake --build cmake-build-release --target all
After that, the main self-executable utility will appear in thecmake-build-release
directory under the nameproj
. The tests can be run by launching thetest
file located nearby.
- 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 thesrc
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 fromexternal linkage
from others compilation units by adding them to the anonymous namespace or adding the keywordstatic
.