Based on this blog post where I describe how to setup a modern and cross-platform C++ environment.
Features:
- CMake config for library, executable, and test.
- Depends on Catch2 and fmt installed from vcpkg.
- VSCode setup (config and extension recommendations)
Note (from the author): Some of my personal settings are hardcoded.
First configure via cmake
(where DCMAKE_TOOLCHAIN_FILE
matches your vcpkg path):
$ cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=C:/Users/Sam/Development/vcpkg/scripts/buildsystems/vcpkg.cmake
If that was successful, build via cmake --build
:
$ cmake --build build
$ ./build/Debug/main.exe
Greetings stranger. Or should I say: Hello world!
Run tests via ctest
:
$ cd build
$ ctest --output-on-failure