- For a better package management experience like
npm
, we usevcpkg
& CMake. vcpkg can also generate Visual Studio project files. - For a better coding and intelligence experience, we use VSCode. VSCode is also much more faster than Visual Studio.
All dependencies should be defined in vcpkg.json
, for more information, see the manifest docs.
git clone --recurse-submodules https://github.com/upupming/vscode-qt-cmake-vcpkg-template.git
.\vcpkg\bootstrap-vcpkg.bat
# install manually (optional, vcpkg can install dependencies automatically when configuring project)
# Note that install manually will got deps in `vcpkg_installed` folder, but cMake will install in `build/vcpkg_installed` folder
# .\vcpkg\vcpkg --feature-flags=manifests,versions install
After bootstrapped, You can just run CMake and all dependencies will automatically get installed to build/vcpkg_installed
folder.
CMake can find the include directories and supply them to VSCode intelligence. For example, for the dcmtk
library, we add this in the CMakeLists.txt
:
find_package(dcmtk REQUIRED)
# Add the given directories to those the compiler uses to search for include files.
include_directories(${DCMTK_INCLUDE_DIR})
And then in .vscode/settings.json
, we use CMake tools as the configuration provider:
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
This will make VSCode intelligence (#include <dcmtk...>
and autocomplete) work seamlessly.
- CMake -> Configure. This will generate Visual Studio project files.
- CMake -> Build. This will build the
.exe
binary. - You can just press
F5
or use the debug button on the left sidebar for debug, thelaunch.json
has been configured correctly. For each run, CMake Task will executed before start the built exe. - vcpkg will link the lib to exe and copy the DLLs to the exe folder automatically, how easy it is.
- GitHub Actions for auto build
- https://github.com/microsoft/vcpkg
- https://vcpkg.info/
- https://vcpkgx.com/
- https://github.com/microsoft/STL
- https://github.com/miredirex/cmake-vcpkg-example/
- https://github.com/microsoft/vcpkg/blob/master/docs/users/manifests.md
- https://www.youtube.com/watch?v=iZeK3Ie5Fz0
- https://cliutils.gitlab.io/modern-cmake/