Skip to content

Commit

Permalink
Add demonstration of vcpkg features
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia committed Dec 6, 2024
1 parent f09e3fc commit 960542a
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 98 deletions.
44 changes: 22 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
129 changes: 65 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
# 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

Use the following commands to build the project:

```
cmake -B build
cmake --build build
```

## cmake.toml

Under the hood cmkr generates the `CMakeLists.txt` required to build this project from the `cmake.toml` file:

```toml
[project]
name = "vcpkg_template"

# See https://vcpkg.link for available packages
# Chose a version from https://github.com/microsoft/vcpkg/releases
[vcpkg]
version = "2024.11.16"
packages = [
"fmt",
"sqlite3",
"mylib",
]
overlay = "vcpkg-overlay"

# 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",
"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).
# 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

Use the following commands to build the project:

```
cmake -B build
cmake --build build
```

## cmake.toml

Under the hood cmkr generates the `CMakeLists.txt` required to build this project from the `cmake.toml` file:

```toml
[project]
name = "vcpkg_template"

# See https://vcpkg.link for available packages
# Chose a version from https://github.com/microsoft/vcpkg/releases
[vcpkg]
version = "2024.11.16"
packages = [
"fmt",
# disable default features (core) and enable DBSTAT virtual table (dbstat)
"sqlite3[core,dbstat]",
"mylib",
]
overlay = "vcpkg-overlay"

# 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",
"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).
3 changes: 2 additions & 1 deletion cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ name = "vcpkg_template"
version = "2024.11.16"
packages = [
"fmt",
"sqlite3",
# disable default features (core) and enable DBSTAT virtual table (dbstat)
"sqlite3[core,dbstat]",
"mylib",
]
overlay = "vcpkg-overlay"
Expand Down
24 changes: 14 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include <fmt/format.h>
#include <sqlite3.h>
#include <mylib/version.hpp>
#include <mylib/stringutils.hpp>

int main()
{
fmt::print("SQLite version: {}\n", sqlite3_libversion());
fmt::print("{} version: {}\n", mylib::reverse("bilym"), mylib::version());
}
#include <fmt/format.h>
#include <sqlite3.h>
#include <mylib/version.hpp>
#include <mylib/stringutils.hpp>

int main()
{
fmt::print("SQLite version: {} (DBSTAT={})\n",
sqlite3_libversion(),
sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB")
);

fmt::print("{} version: {}\n", mylib::reverse("bilym"), mylib::version());
}
6 changes: 5 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"fmt",
"sqlite3",
{
"name": "sqlite3",
"default-features": false,
"features": ["dbstat"]
},
"mylib"
],
"description": "",
Expand Down

0 comments on commit 960542a

Please sign in to comment.