-
Clone this repo:
git clone <link to this repo> <project name>
If you have it already, you can clone from local directory:
git clone --local <path to this repo> <project name>
-
Rename this repo
Replace
cpp-single-template
with your project name inCMakeList.txt
,vcpkg.json
, andREADME.md
Rename
.vscode/cpp-single-template.code-workspace
to.vscode/<project name>.code-workspace
Remove "How to use this template" section completely by remove line 3 to 30 (inclusive)
-
Start as a new repo
Delete
.git
directory, then rungit init git submodule add https://github.com/microsoft/vcpkg vcpkg git add . git commit -m "Init"
Use CMake presets, list all avaliable presets:
cmake --list-presets
Then choose one, for example on Windows:
cmake --preset vs2022-default
On Windows, if you're not using vs2022-...
presets, you'll need to make sure to have g++
, clang++
, clang-cl
, or cl
avaliable on your console before calling CMake configure.
Make sure to install needed libraries before running CMake configure.
- Add the library's names to
vcpkg.json
"dependencies": [ ... ]"
- Run
cmake --preset ...
again.vcpkg
will build and installed those libraries for you. In addition to that,vcpkg
will tell you how to find and link those libraries with CMake. - Add
find_package(...)
andtarget_link_libraries(...)
toCMakeList.txt
You only need Microsoft C/C++ extension (cpptools).
- Intenllisense profiles are stored in
.vscode/c_cpp_properties.json
- Build commands are store in
.vscode/tasks.json
- Debug profiles are stored in
.vscode/launch.json
- Open
.vscode/cpp-single-template.code-workspace
with VS Code
- For
ninjam-linux
: it works out of the box, nothing to do.
-
For MinGW presets: you need to set
MINGW_ROOT
environment var to/mingw64
folder (or/mingw32
). For exampleD:\msys64\mingw64
-
For MSVC presets: you need to open VS Code with
vcvars64.bat
(orvcvars32.bat
) enabled. For example from powershell terminal run:cmd "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" code .vscode/cpp-single-template.code-workspace