Git Product home page Git Product logo

cppcmakevcpkgtemplate's Introduction

hosted-ninja-vcpkg_submod-autocache hosted-pure-workflow

A C++ project template based on CMake and vcpkg

Content

This repository contains a C++ based project template that leverages vcpkg and CMake's CMakePresets.json to build and test C++ source code.

Supports Linux/macOS/Windows on x64 and arm64 platforms.

vcpkg is driven to use its binary caching feature storing the content in the GitHub Action cache, hence speeding up workflows by reusing previously built packages.

Key features:

  • CMakePresets.json allows to run the same build either locally on your IDE and on GitHub runners.
  • vcpkg greatly helps in pulling and building the needed dependencies (e.g. libraries) which are cached for reuse on GitHub Action cache.

GitHub Action workflows

The repository provides also two GitHub workflows to build the project on GitHub runners. Both builds and tests the project using vcpkg and CMake, the only key difference is their implementation:

  • hosted-pure-workflow.yml: it is a pure workflow which does not use unneeded GitHub Actions that cannot run locally on your development machine. On the other hand it is directly using the CMake, Ninja, vcpkg and the C++ build tools.
  • hosted-ninja-vcpkg_submod.yml: it is a concise workflow based on the custom GitHub Actions get-cmake, run-vcpkg and run-cmake which simplify and shorten the workflow verbosity while adding some goodies like vcpkg binary caching stored on GH's cache and inline error annotations.

Rationale

The main idea of this C++ project template is to show how to obtain a perfectly reproducible software development process that can be run anywhere without any difference and no surprises, either locally using your preferred tools/IDE, either remotely on build agents typically used for continuous integration.

Integrated Development Environment (IDE) Support

The major C++ IDEs should already support CMakePresets.json and require no particular configuration.

For example Visual Studio Code with the CMake Tools extension let you to open the root folder of this repository, and select in the status bar the CMake preset (e.g. ninja-multi-vcpkg), as show in the following image:

CMake's preset selection in the status bar of Visual Studio Code


License

All the content in this repository is licensed under the MIT License.

Copyright © 2021-2022-2023 Luca Cappa

cppcmakevcpkgtemplate's People

Contributors

amirmasoudabdol avatar amrelsayyad avatar jdabello avatar lukka avatar magnesj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cppcmakevcpkgtemplate's Issues

Why build in the source dir?

"binaryDir": "${sourceDir}/builds/${presetName}",

Why do you put the build directory inside the source directory instead of doing an out-of-tree build?

I thought best practices recommended out of tree builds.

Licence question

Hey

I am a young programmer and i would like to use your template for my projects.
Am i allowed with the licence you use, to "take" this template, manipulate it and use it in my own projects?

How to change preset in Visual Studio [Debug, Release, RelWithDebInfo etc.]

Hi,

Firstly, thanks for your template. I use it in all my C++ projects now.

By default visual studio builds the "Debug" preset and I haven't been able to find a way to use the other presets. It seems you can change this in VS code but my vscode builds keep failing.

I have searched everywhere for how to do this. Maybe I'm missing something stupid.

There is a way to build using cmake like in the yaml file, but this seems to always reconfigure everything and doesn't use cached packages.

Any help would be appreciated, thanks.

Having minimal dependencies

Hi,

vcpkg.json doesn't allow to have minimal dependencies.
you can't specify qtbase[core,gui] for example.

How did you manage to overcome it?

Regards,
Alex

[qt5-base] fails to build on mac runner "xcodebuild: error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" cannot be located."

I started a fresh clone of this and tried to use qt5-base but the runner reports:

https://github.com/ericfont/SerialAudio/runs/4172526046?check_suite_focus=true#step:5:1533

  Building package qt5-base[core]:x64-osx...
  -- Figuring out qt target mkspec. Target arch x64
  -- Target mkspec set to: macx-clang
  -- Host mkspec not set. Qt's own buildsystem will try to figure out the host system
  -- Downloading https://download.qt.io/official_releases/qt/5.15/5.15.2/submodules/qtbase-everywhere-src-5.15.2.tar.xz;https://mirrors.ocf.berkeley.edu/qt/official_releases/qt/5.15/5.15.2/submodules/qtbase-everywhere-src-5.15.2.tar.xz -> qtbase-everywhere-src-5.15.2.tar.xz...
  -- Extracting source /Users/runner/work/SerialAudio/SerialAudio/vcpkg/downloads/qtbase-everywhere-src-5.15.2.tar.xz
  -- Applying patch patches/winmain_pro.patch
  -- Applying patch patches/windows_prf.patch
  -- Applying patch patches/qt_app.patch
  -- Applying patch patches/gui_configure.patch
  -- Applying patch patches/icu.patch
  -- Applying patch patches/xlib.patch
  -- Applying patch patches/egl.patch
  -- Applying patch patches/zstdd.patch
  -- Applying patch patches/mysql_plugin_include.patch
  -- Applying patch patches/mysql-configure.patch
  -- Applying patch patches/Qt5BasicConfig.patch
  -- Applying patch patches/Qt5PluginTarget.patch
  -- Applying patch patches/create_cmake.patch
  -- Applying patch patches/Qt5GuiConfigExtras.patch
  -- Applying patch patches/limits_include.patch
  -- Using source at /Users/runner/work/SerialAudio/SerialAudio/vcpkg/buildtrees/qt5-base/src/5.15.2-fa8de595e1.clean
  xcodebuild: error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" cannot be located.
  xcrun: error: unable to lookup item 'SDKVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
  -- Detected OSX SDK Version: 
  CMake Error at ports/qt5-base/portfile.cmake:323 (string):
  Error:   string sub-command REGEX, mode MATCH needs at least 5 arguments total to

Why are all the caches named 'vcpkg'?

I'm not sure if this is coming from your github action or from vcpkg, but I get a cache per dependency, but they're all named 'vcpkg' so I can't see what they are and I can't invalidate a particular one manually should that become necessary.

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.