stamen

Static Menu Generator
git clone git://git.dimitrijedobrota.com/stamen.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit 5694a5e39b554a1c6ba15846ea1f47d8f42f8a9b
parent 8f5d29ce6ed728e91d790000690db2649274d15a
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Sun, 9 Mar 2025 20:45:45 +0100

Add support for vcpkg

Diffstat:
M BUILDING.md | ++++
M CMakeLists.txt | ++++ ------
M CMakePresets.json | ++++++++++++++++++++++++++ ----------------------
M HACKING.md | ++++++++++++++++ --------------------------
M README.md | +++ ------
M cmake/dev-mode.cmake | +++++++
M cmake/install-config.cmake | ++++++++ -
A vcpkg-configuration.json | +++++++++++++++
A vcpkg.json | +++++++++++++++++++++++

9 files changed, 106 insertions(+), 61 deletions(-)


diff --git a/ BUILDING.md b/ BUILDING.md

@@ -1,5 +1,9 @@ # Building with CMake
## Dependencies
For a list of dependencies, please refer to [vcpkg.json](vcpkg.json).
## Build This project doesn't require any special command-line flags to build to keep

diff --git a/ CMakeLists.txt b/ CMakeLists.txt

@@ -13,16 +13,12 @@ project( include(cmake/project-is-top-level.cmake) include(cmake/variables.cmake)
find_package(poafloc 1.2 CONFIG REQUIRED)
find_package(cemplate 0.2 CONFIG REQUIRED)
# ---- Declare library ---- add_library( stamen_stamen source/stamen.cpp )
target_link_libraries(stamen_stamen PUBLIC poafloc::poafloc)
add_library(stamen::stamen ALIAS stamen_stamen) include(GenerateExportHeader)

@@ -66,8 +62,10 @@ target_compile_features(stamen_stamen PUBLIC cxx_std_20) add_executable(stamen_exe source/generate.cpp) add_executable(stamen::exe ALIAS stamen_exe)
target_link_libraries(stamen_exe PRIVATE cemplate::cemplate)
target_link_libraries(stamen_exe PRIVATE stamen::stamen)
find_package(poafloc 1.2 CONFIG REQUIRED)
find_package(cemplate 0.2 CONFIG REQUIRED)
target_link_libraries(stamen_exe PRIVATE stamen::stamen poafloc::poafloc cemplate::cemplate)
set_property(TARGET stamen_exe PROPERTY OUTPUT_NAME stamen) target_compile_features(stamen_exe PRIVATE cxx_std_20)

diff --git a/ CMakePresets.json b/ CMakePresets.json

@@ -7,26 +7,25 @@ }, "configurePresets": [ {
"name": "cmake-pedantic",
"name": "dev-mode",
"hidden": true,
"warnings": {
"dev": true,
"deprecated": true,
"uninitialized": true,
"unusedCli": true,
"systemVars": false
},
"errors": {
"dev": true,
"deprecated": true
"cacheVariables": {
"stamen_DEVELOPER_MODE": "ON",
"VCPKG_MANIFEST_FEATURES": "test"
} }, {
"name": "dev-mode",
"name": "vcpkg",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "vcpkg-win64-static",
"hidden": true,
"inherits": "cmake-pedantic",
"cacheVariables": {
"stamen_DEVELOPER_MODE": "ON"
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md"
} }, {

@@ -93,7 +92,10 @@ "name": "ci-darwin", "inherits": ["flags-appleclang", "ci-std"], "generator": "Xcode",
"hidden": true
"hidden": true,
"cacheVariables": {
"CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE": "PRE_TEST"
}
}, { "name": "ci-win64",

@@ -112,12 +114,13 @@ "CMAKE_BUILD_TYPE": "Coverage", "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage"
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage",
"CMAKE_MAP_IMPORTED_CONFIG_COVERAGE": "Coverage;RelWithDebInfo;Release;Debug;"
} }, { "name": "ci-coverage",
"inherits": ["coverage-linux", "dev-mode"],
"inherits": ["coverage-linux", "dev-mode", "vcpkg"],
"cacheVariables": { "COVERAGE_HTML_COMMAND": "" }

@@ -125,10 +128,11 @@ { "name": "ci-sanitize", "binaryDir": "${sourceDir}/build/sanitize",
"inherits": ["ci-linux", "dev-mode"],
"inherits": ["ci-linux", "dev-mode", "vcpkg"],
"cacheVariables": { "CMAKE_BUILD_TYPE": "Sanitize",
"CMAKE_CXX_FLAGS_SANITIZE": "-U_FORTIFY_SOURCE -O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common"
"CMAKE_CXX_FLAGS_SANITIZE": "-U_FORTIFY_SOURCE -O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common",
"CMAKE_MAP_IMPORTED_CONFIG_SANITIZE": "Sanitize;RelWithDebInfo;Release;Debug;"
} }, {

@@ -146,15 +150,15 @@ }, { "name": "ci-macos",
"inherits": ["ci-build", "ci-darwin", "dev-mode", "ci-multi-config"]
"inherits": ["ci-build", "ci-darwin", "dev-mode", "ci-multi-config", "vcpkg"]
}, { "name": "ci-ubuntu",
"inherits": ["ci-build", "ci-linux", "clang-tidy", "cppcheck", "dev-mode"]
"inherits": ["ci-build", "ci-linux", "clang-tidy", "vcpkg", "cppcheck", "dev-mode"]
}, { "name": "ci-windows",
"inherits": ["ci-build", "ci-win64", "dev-mode", "ci-multi-config"]
"inherits": ["ci-build", "ci-win64", "dev-mode", "ci-multi-config", "vcpkg", "vcpkg-win64-static"]
} ] }

diff --git a/ HACKING.md b/ HACKING.md

@@ -41,7 +41,7 @@ the project: { "name": "dev", "binaryDir": "${sourceDir}/build/dev",
"inherits": ["dev-mode", "ci-<os>"],
"inherits": ["dev-mode", "vcpkg", "ci-<os>"],
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }

@@ -87,6 +87,17 @@ in the terminal. > in `Tools > Options > CMake` **prior to opening the project**, after which > you can manually configure using `Project > Configure Cache`.
### Dependency manager
The above preset will make use of the [vcpkg][vcpkg] dependency manager. After
installing it, make sure the `VCPKG_ROOT` environment variable is pointing at
the directory where the vcpkg executable is. On Windows, you might also want
to inherit from the `vcpkg-win64-static` preset, which will make vcpkg install
the dependencies as static libraries. This is only necessary if you don't want
to setup `PATH` to run tests.
[vcpkg]: https://github.com/microsoft/vcpkg
### Configure, build and test If you followed the above instructions, then you can configure, build and test

@@ -135,36 +146,15 @@ These targets run the clang-format tool on the codebase to check errors and to fix them respectively. Customization available using the `FORMAT_PATTERNS` and `FORMAT_COMMAND` cache variables.
#### `run-exe`
Runs the executable target `exe_exe`.
#### `spell-check` and `spell-fix` These targets run the codespell tool on the codebase to check errors and to fix them respectively. Customization available using the `SPELL_COMMAND` cache variable.
## Running tests on Windows with `BUILD_SHARED_LIBS=ON`
If you are building a shared library on Windows, you must add the path to the
DLL file to `PATH` when you want to run tests. One way you could do that is by
using PowerShell and writing a script for it, e.g. `env.ps1` at the project
root:
```powershell
$oldPrompt = (Get-Command prompt).ScriptBlock
function prompt() { "(Debug) $(& $oldPrompt)" }
$VsInstallPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -Property InstallationPath
$Env:Path += ";$VsInstallPath\Common7\IDE;$Pwd\build\dev\Debug"
```
Then you can source this script by running `. env.ps1`. This particular
example will only work for Debug builds.
### Passing `PATH` to editors
Make sure you launch your editor of choice from the console with the above
script sourced. Look for `(Debug)` in the prompt to confirm, then run e.g.
`code .` for VScode or `devenv .` for Visual Studio.
[1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html [2]: https://cmake.org/download/

diff --git a/ README.md b/ README.md

@@ -22,18 +22,16 @@ The main advantage of stamen is two modes it can operate in: * CMake 3.14 or latter * Compiler with C++20 support (tested: clang 19.1.7, gcc 14.2.1)
* [`Cemplate 0.2`](https://github.com/DimitrijeDobrota/cemplate)
* [`Poafloc 1.2`](https://github.com/DimitrijeDobrota/poafloc)
## Building and installing
See the [BUILDING](BUILDING.md) document.
See the [`BUILDING`](BUILDING.md) document.
## Usage
> Please reference example folder for relevant usage example.
> Please reference example folder for relevant usage examples.
> Refer to example/CMakeLists.txt to see how to integrate stamen into build system

@@ -169,7 +167,6 @@ See the [`CONTRIBUTING`](CONTRIBUTING.md) document. ## License
This project is licensed under the MIT License -
see the [`LICENSE`](LICENSE.md) file for details
This project is licensed under the MIT License - see the [`LICENSE`](LICENSE.md) file for details

diff --git a/ cmake/dev-mode.cmake b/ cmake/dev-mode.cmake

@@ -1,5 +1,12 @@ include(cmake/folders.cmake)
add_custom_target(
run-exe
COMMAND stamen_exe
VERBATIM
)
add_dependencies(run-exe stamen_exe)
option(ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) if(ENABLE_COVERAGE) include(cmake/coverage.cmake)

diff --git a/ cmake/install-config.cmake b/ cmake/install-config.cmake

@@ -1,1 +1,8 @@
include("${CMAKE_CURRENT_LIST_DIR}/stamenTargets.cmake")
include(CMakeFindDependencyMacro)
find_dependency(cemplate)
find_dependency(poafloc)
if(cemplate_FOUND AND poafloc_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/stamenTargets.cmake")
endif()

diff --git a/ vcpkg-configuration.json b/ vcpkg-configuration.json

@@ -0,0 +1,15 @@
{
"default-registry": {
"kind": "git",
"baseline": "566f9496b7e00ee0cc00aca0ab90493d122d148a",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "git",
"repository": "git://git.dimitrijedobrota.com/vcpkg-registry.git",
"baseline": "487d7c36bb87d45fb7f98f5bd6c7dd0bed9b8c08",
"packages": [ "cemplate", "poafloc" ]
}
]
}

diff --git a/ vcpkg.json b/ vcpkg.json

@@ -0,0 +1,23 @@
{
"name": "stamen",
"version-semver": "1.3.0",
"dependencies": [
{
"name": "cemplate",
"version>=": "0.2.0"
},
{
"name": "poafloc",
"version>=": "1.2.0"
}
],
"default-features": [],
"features": {
"test": {
"description": "Dependencies for testing",
"dependencies": [
]
}
},
"builtin-baseline": "eba7c6a894fce24146af4fdf161fef8e90dd6be3"
}