-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update cmkr and showcase latest features
- Loading branch information
Showing
13 changed files
with
337 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
name: CMake | ||
|
||
on: [push, pull_request] | ||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
# Build every 6 days to avoid costly cache rebuilds | ||
- cron: 0 0 */6 * * # https://crontab.guru/#0_0_*/6_*_* | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
fail-fast: false | ||
matrix: | ||
os: [windows-2019, macos-10.15, ubuntu-20.04] | ||
os: [windows-latest, macos-latest, ubuntu-latest] | ||
env: | ||
BUILD_TYPE: Release | ||
BUILD_TYPE: "Release" | ||
CMAKE_GENERATOR: "Ninja" | ||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
- name: Compile with gcc 10 on ubuntu | ||
if: ${{ matrix.os == 'ubuntu-20.04' }} | ||
run: | | ||
echo "CC=gcc-10" >> $GITHUB_ENV | ||
echo "CXX=g++-10" >> $GITHUB_ENV | ||
- name: Build | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# Reference: https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache | ||
- name: Export GitHub Actions cache environment variables | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | ||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | ||
- name: Install Ninja | ||
uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # v5 | ||
|
||
- name: Visual Studio Development Environment | ||
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1 | ||
|
||
- name: CMake Build | ||
run: | | ||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} | ||
cmake -B build "-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}" | ||
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel | ||
- name: Run Tests | ||
run: | | ||
build/example |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,64 @@ | ||
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/from-referrer/) | ||
|
||
# vcpkg_template | ||
|
||
This is a template showcasing [cmkr](https://github.com/build-cpp/cmkr) together with [vcpkg](https://github.com/microsoft/vcpkg) for frictionless cross platform dependency management with CMake. | ||
|
||
## Building (IDE) | ||
|
||
Clone this repository and open it in your favorite IDE with CMake support (Visual Studio, CLion, Qt Creator). Everything should work out of the box. | ||
## Building | ||
|
||
## Building (command line) | ||
Use the following commands to build the project: | ||
|
||
``` | ||
cmake -Bbuild | ||
cmake -B build | ||
cmake --build build | ||
``` | ||
|
||
Then open the `.sln` (Windows) or run `make` (Unix) from the `build` directory. | ||
|
||
## cmake.toml | ||
|
||
Under the hood cmkr generates the `CMakeLists.txt` required to build this project from the `cmake.toml` file: | ||
|
||
```toml | ||
[cmake] | ||
version = "3.15" | ||
cmkr-include = "cmake/cmkr.cmake" | ||
|
||
[project] | ||
name = "vcpkg_template" | ||
|
||
# See https://vcpkg.io/en/packages.html for available packages | ||
# See https://vcpkg.link for available packages | ||
# Chose a version from https://github.com/microsoft/vcpkg/releases | ||
[vcpkg] | ||
version = "2021.05.12" | ||
packages = ["fmt", "sqlite3"] | ||
version = "2024.11.16" | ||
packages = [ | ||
"fmt", | ||
"sqlite3", | ||
"mylib", | ||
] | ||
overlay = "vcpkg-overlay" | ||
|
||
[find-package] | ||
fmt = { version = "*" } | ||
unofficial-sqlite3 = { version = "*" } | ||
# Make the packages available to CMake | ||
[find-package.fmt] | ||
[find-package.unofficial-sqlite3] | ||
[find-package.unofficial-mylib] | ||
|
||
[target.example] | ||
type = "executable" | ||
sources = ["src/main.cpp"] | ||
link-libraries = ["fmt::fmt", "unofficial::sqlite3::sqlite3"] | ||
link-libraries = [ | ||
"fmt::fmt", | ||
"unofficial::sqlite3::sqlite3", | ||
"unofficial::mylib::mylib", | ||
] | ||
``` | ||
|
||
## Vcpkg overlay | ||
|
||
The `[vcpkg].overlay` key points to a local folder used as an overlay for vcpkg ports and triplets: | ||
|
||
```sh | ||
vcpkg-overlay | ||
├── mylib # custom port | ||
│ ├── CMakeLists.txt | ||
│ ├── portfile.cmake | ||
│ ├── usage | ||
│ └── vcpkg.json | ||
└── x64-windows.cmake # custom triplet | ||
``` | ||
|
||
The `vcpkg-overlay/mylib` [overlay port](https://learn.microsoft.com/en-us/vcpkg/concepts/overlay-ports) is used to make the example [mylib](https://gitlab.com/mrexodia/mylib) available without having to fork the vcpkg repository or create a custom registry. | ||
|
||
The `vcpkg-overlay/x64-windows.cmake` [overlay triplet](https://learn.microsoft.com/en-us/vcpkg/users/examples/overlay-triplets-linux-dynamic) is used to always build static libraries for Windows (instead of shared libraries, which is normally the default). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
[cmake] | ||
version = "3.15" | ||
cmkr-include = "cmake/cmkr.cmake" | ||
|
||
[project] | ||
name = "vcpkg_template" | ||
|
||
# See https://vcpkg.io/en/packages.html for available packages | ||
# See https://vcpkg.link for available packages | ||
# Chose a version from https://github.com/microsoft/vcpkg/releases | ||
[vcpkg] | ||
version = "2021.05.12" | ||
packages = ["fmt", "sqlite3"] | ||
version = "2024.11.16" | ||
packages = [ | ||
"fmt", | ||
"sqlite3", | ||
"mylib", | ||
] | ||
overlay = "vcpkg-overlay" | ||
|
||
[find-package] | ||
fmt = { version = "*" } | ||
unofficial-sqlite3 = { version = "*" } | ||
# Make the packages available to CMake | ||
[find-package.fmt] | ||
[find-package.unofficial-sqlite3] | ||
[find-package.unofficial-mylib] | ||
|
||
[target.example] | ||
type = "executable" | ||
sources = ["src/main.cpp"] | ||
link-libraries = ["fmt::fmt", "unofficial::sqlite3::sqlite3"] | ||
link-libraries = [ | ||
"fmt::fmt", | ||
"unofficial::sqlite3::sqlite3", | ||
"unofficial::mylib::mylib", | ||
] |
Oops, something went wrong.