From 960542a63d3eac9b8e95a5e303fbd76f597acad9 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 6 Dec 2024 18:10:37 +0100 Subject: [PATCH] Add demonstration of vcpkg features --- LICENSE | 44 +++++++++--------- README.md | 129 ++++++++++++++++++++++++++------------------------- cmake.toml | 3 +- src/main.cpp | 24 ++++++---- vcpkg.json | 6 ++- 5 files changed, 108 insertions(+), 98 deletions(-) diff --git a/LICENSE b/LICENSE index 30aac2c..127a5bc 100644 --- a/LICENSE +++ b/LICENSE @@ -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. \ No newline at end of file diff --git a/README.md b/README.md index e7d7e2c..91ec3f9 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/cmake.toml b/cmake.toml index 652f027..945e188 100644 --- a/cmake.toml +++ b/cmake.toml @@ -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" diff --git a/src/main.cpp b/src/main.cpp index 429ebf5..9b286b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,14 @@ -#include -#include -#include -#include - -int main() -{ - fmt::print("SQLite version: {}\n", sqlite3_libversion()); - fmt::print("{} version: {}\n", mylib::reverse("bilym"), mylib::version()); -} \ No newline at end of file +#include +#include +#include +#include + +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()); +} diff --git a/vcpkg.json b/vcpkg.json index 597f958..516c0de 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -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": "",