Coder Social home page Coder Social logo

vscode-vcpkg-template2's Introduction

vscode-vcpkg-template

  • For a better package management experience like npm, we use vcpkg & 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.

Get Started

Install dependencies

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.

VSCode Configuration

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.

Run the project

  1. CMake -> Configure. This will generate Visual Studio project files.
  2. CMake -> Build. This will build the .exe binary.
  3. You can just press F5 or use the debug button on the left sidebar for debug, the launch.json has been configured correctly. For each run, CMake Task will executed before start the built exe.
  4. vcpkg will link the lib to exe and copy the DLLs to the exe folder automatically, how easy it is.

Todo

  • GitHub Actions for auto build

Useful information

  1. https://github.com/microsoft/vcpkg
  2. https://vcpkg.info/
  3. https://vcpkgx.com/
  4. https://github.com/microsoft/STL
  5. https://github.com/miredirex/cmake-vcpkg-example/
  6. https://github.com/microsoft/vcpkg/blob/master/docs/users/manifests.md
  7. https://www.youtube.com/watch?v=iZeK3Ie5Fz0
  8. https://cliutils.gitlab.io/modern-cmake/

vscode-vcpkg-template2's People

Contributors

alexkissijr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.