- Ensure
vcpkgis installed. Get the package manager on your machine.
- clone
vcpkginto any location of your choice,
git clone https://github.com/microsoft/vcpkg.git
- cd into the install path and run the bootstrap bat file.
cd vcpkg; .\bootstrap-vcpkg.bat
- Create a new
CMakeUserPresets.jsonin the root of the project to accompany theCMakePresets.json. Your CMakeUserPresets.json should look something like this...
{
"version": 3,
"configurePresets": [
{
"name": "debug",
"inherits": "base",
"environment": {
"VCPKG_ROOT": "path-to-vcpkg"
}
},
{
"name": "release",
"inherits": "debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS": "/DWIN32 /D_WINDOWS /O2 /GR /EHsc"
}
}
],
"buildPresets": [
{
"name": "default-build-windows",
"displayName": "Default",
"configurePreset": "debug",
"description": "Vanilla build"
},
{
"name": "release_build_windows",
"configurePreset": "release",
"displayName": "Release",
"description": "Vanilla Build"
}
]
}You can directly copy this and change the VCPKG_ROOT path value to the instance location of vcpkg on your machine.
Note: Do not commit the
CMakeUserPresets.jsonfile, Ever!!!
- To download the dependencies listed in the project's vcpkg.json, run this:
vcpkg install --triplet <triplet>for example, in my Visual Studio project, I use this:
vcpkg install --triplet x64-windows
- Then in your IDE(in my case Visual Studio 2022), reset Cache and Configure the project.
- Build all projects.
- Run the
installExecutables.
There are executables such as
Game.exeandPurityEditor.exein the install directories${projectDir}/out/install/${presetName}/bin, accompanied by the required runtime artefacts. Running these executables instead of the ones in the target binary directories will resolve theDLL not found errors.
No more manually copying dlls to executable location. You get the latest build in the install directory.
For more help, check the vcpkg documentation here
To resolve relative path issues, use the json snippet below to setup your launch.vs.json
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "PurityEditor.exe (Install)",
"name": "PurityEditor.exe (Install)",
"currentDir": "${workspaceRoot}"
},
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "PurityGem.exe (Install)",
"name": "PurityGem.exe (Install)",
"currentDir": "${workspaceRoot}"
}
]
}Everything above also applies when using VS Code. Install the following extensions:
CMake Tools(ms-vscode.cmake-tools)C/C++(ms-vscode.cpptools)Child Process DebuggingFind it here
- Open the repository root in VS Code.
- Make sure
VCPKG_ROOTis available in the VS Code environment, or set it inCMakeUserPresets.jsonas described above. - Open the Command Palette and run
CMake: Select Configure Preset, then selectdebug. - Run
CMake: Configureand thenCMake: Buildfrom the Command Palette. The build preset produces the binaries underout/build/debug. - Run
CMake: Installbefore launching the editor or game. The runnable executables are installed underout/install/debug/binso their runtime DLLs are available. - Open the Run and Debug view and create a C++ launch configuration for the installed executable. Use the repository root as the working directory and select
PurityEditor.exeorPurityGem.exefromout/install/debug/bin. - Use the
Child Process Debuggingextension when the process being debugged starts additional executables. Start the parent process through the Run and Debug view so child-process attachment can be enabled by the extension.
For a repeatable launch configuration, create .vscode/launch.json with the following and adjust the executable name when needed:
{
"version": "0.2.0",
"configurations": [
{
"name": "PurityEditor (Install)",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/out/install/debug/bin/PurityEditor.exe",
"cwd": "${workspaceFolder}/out/install/debug/bin",
"stopAtEntry": false,
"console": "externalTerminal",
"autoAttachChildProcess": true
},
{
"name": "PurityGem (Install)",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/out/install/debug/bin/PurityGem.exe",
"cwd": "${workspaceFolder}/out/install/debug/bin",
"stopAtEntry": false,
"console": "externalTerminal",
"autoAttachChildProcess": true
}
]
}Everything above is to configure Visual Studio Community. Do the following in addition if you wish to build the projects and contribute using either CLion or VS Code...
- Open CLion configurations.
- If no targets are set, create new targets for the following(Select
CMake Applicationas Target type).- PurityEditor
exe - Purity
dll - PurityGem
exe - Commons
dll - IsleMath
dll - ImGuiFileDialog
lib
- PurityEditor
- For all Targets of type
exe, Set theExecutablefield to the target found in theinstallfolder.-
e.g C:\Path-to-PurityEngine\out\install\debug\bin\PurityGem.exe
-
Make sure the executables selected are the one located in the install folder at
out/install/debug/binfor example
-
- Set the working directory of all the targets to the
$ProjectFileDir$macro. - Optionally, make the toolchain the Visual Studio Toolchain. Not tested with MinGW.