Skip to content

Commit dfecb37

Browse files
committed
Add demonstration of vcpkg features
1 parent f09e3fc commit dfecb37

File tree

5 files changed

+109
-98
lines changed

5 files changed

+109
-98
lines changed

LICENSE

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
Boost Software License - Version 1.0 - August 17th, 2003
2-
3-
Permission is hereby granted, free of charge, to any person or organization
4-
obtaining a copy of the software and accompanying documentation covered by
5-
this license (the "Software") to use, reproduce, display, distribute,
6-
execute, and transmit the Software, and to prepare derivative works of the
7-
Software, and to permit third-parties to whom the Software is furnished to
8-
do so, all subject to the following:
9-
10-
The copyright notices in the Software and this entire statement, including
11-
the above license grant, this restriction and the following disclaimer,
12-
must be included in all copies of the Software, in whole or in part, and
13-
all derivative works of the Software, unless such copies or derivative
14-
works are solely in the form of machine-executable object code generated by
15-
a source language processor.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20-
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21-
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,65 @@
1-
# vcpkg_template
2-
3-
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.
4-
5-
## Building
6-
7-
Use the following commands to build the project:
8-
9-
```
10-
cmake -B build
11-
cmake --build build
12-
```
13-
14-
## cmake.toml
15-
16-
Under the hood cmkr generates the `CMakeLists.txt` required to build this project from the `cmake.toml` file:
17-
18-
```toml
19-
[project]
20-
name = "vcpkg_template"
21-
22-
# See https://vcpkg.link for available packages
23-
# Chose a version from https://github.com/microsoft/vcpkg/releases
24-
[vcpkg]
25-
version = "2024.11.16"
26-
packages = [
27-
"fmt",
28-
"sqlite3",
29-
"mylib",
30-
]
31-
overlay = "vcpkg-overlay"
32-
33-
# Make the packages available to CMake
34-
[find-package.fmt]
35-
[find-package.unofficial-sqlite3]
36-
[find-package.unofficial-mylib]
37-
38-
[target.example]
39-
type = "executable"
40-
sources = ["src/main.cpp"]
41-
link-libraries = [
42-
"fmt::fmt",
43-
"unofficial::sqlite3::sqlite3",
44-
"unofficial::mylib::mylib",
45-
]
46-
```
47-
48-
## Vcpkg overlay
49-
50-
The `[vcpkg].overlay` key points to a local folder used as an overlay for vcpkg ports and triplets:
51-
52-
```sh
53-
vcpkg-overlay
54-
├── mylib # custom port
55-
│ ├── CMakeLists.txt
56-
│ ├── portfile.cmake
57-
│ ├── usage
58-
│ └── vcpkg.json
59-
└── x64-windows.cmake # custom triplet
60-
```
61-
62-
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.
63-
64-
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).
1+
# vcpkg_template
2+
3+
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.
4+
5+
## Building
6+
7+
Use the following commands to build the project:
8+
9+
```
10+
cmake -B build
11+
cmake --build build
12+
```
13+
14+
## cmake.toml
15+
16+
Under the hood cmkr generates the `CMakeLists.txt` required to build this project from the `cmake.toml` file:
17+
18+
```toml
19+
[project]
20+
name = "vcpkg_template"
21+
22+
# See https://vcpkg.link for available packages
23+
# Chose a version from https://github.com/microsoft/vcpkg/releases
24+
[vcpkg]
25+
version = "2024.11.16"
26+
packages = [
27+
"fmt",
28+
# disable default features (core) and enable DBSTAT virtual table (dbstat)
29+
"sqlite3[core,dbstat]",
30+
"mylib",
31+
]
32+
overlay = "vcpkg-overlay"
33+
34+
# Make the packages available to CMake
35+
[find-package.fmt]
36+
[find-package.unofficial-sqlite3]
37+
[find-package.unofficial-mylib]
38+
39+
[target.example]
40+
type = "executable"
41+
sources = ["src/main.cpp"]
42+
link-libraries = [
43+
"fmt::fmt",
44+
"unofficial::sqlite3::sqlite3",
45+
"unofficial::mylib::mylib",
46+
]
47+
```
48+
49+
## Vcpkg overlay
50+
51+
The `[vcpkg].overlay` key points to a local folder used as an overlay for vcpkg ports and triplets:
52+
53+
```sh
54+
vcpkg-overlay
55+
├── mylib # custom port
56+
│ ├── CMakeLists.txt
57+
│ ├── portfile.cmake
58+
│ ├── usage
59+
│ └── vcpkg.json
60+
└── x64-windows.cmake # custom triplet
61+
```
62+
63+
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.
64+
65+
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).

cmake.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ name = "vcpkg_template"
77
version = "2024.11.16"
88
packages = [
99
"fmt",
10-
"sqlite3",
10+
# disable default features (core) and enable DBSTAT virtual table (dbstat)
11+
"sqlite3[core,dbstat]",
1112
"mylib",
1213
]
1314
overlay = "vcpkg-overlay"

src/main.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
#include <fmt/format.h>
2-
#include <sqlite3.h>
3-
#include <mylib/version.hpp>
4-
#include <mylib/stringutils.hpp>
5-
6-
int main()
7-
{
8-
fmt::print("SQLite version: {}\n", sqlite3_libversion());
9-
fmt::print("{} version: {}\n", mylib::reverse("bilym"), mylib::version());
10-
}
1+
#include <fmt/format.h>
2+
#include <sqlite3.h>
3+
#include <mylib/version.hpp>
4+
#include <mylib/stringutils.hpp>
5+
6+
int main()
7+
{
8+
fmt::print("SQLite version: {} (DBSTAT={}, JSON1={})\n",
9+
sqlite3_libversion(),
10+
sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB"),
11+
sqlite3_compileoption_used("SQLITE_ENABLE_JSON1")
12+
);
13+
14+
fmt::print("{} version: {}\n", mylib::reverse("bilym"), mylib::version());
15+
}

vcpkg.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
55
"dependencies": [
66
"fmt",
7-
"sqlite3",
7+
{
8+
"name": "sqlite3",
9+
"default-features": false,
10+
"features": ["dbstat"]
11+
},
812
"mylib"
913
],
1014
"description": "",

0 commit comments

Comments
 (0)