display

Layout and Rendering TUI library
git clone git://git.dimitrijedobrota.com/display.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit c0fa9392d151258ba51b2c2dd85bd7490a964c48
parent f5707488a04d7c0d01ad26ee6bdf1eb54f7ed87f
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Mon, 10 Mar 2025 17:05:46 +0100

Add support for vcpkg

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

8 files changed, 87 insertions(+), 51 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/ 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": {
"display_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": {
"display_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

@@ -141,30 +152,5 @@ 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

@@ -15,7 +15,6 @@ staff with it, and figure out the rest as I go.


* CMake 3.14 or latter
* Compiler with C++20 support (tested on clang version 19.1.7)
* [`Stamen 1.3.0`](https://github.com/DimitrijeDobrota/stamen) (for running examples)


## Building and installing

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

@@ -1,1 +1,6 @@

include("${CMAKE_CURRENT_LIST_DIR}/displayTargets.cmake")
include(CMakeFindDependencyMacro)
find_dependency(alec)

if(alec_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/displayTargets.cmake")
endif()

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

@@ -4,7 +4,7 @@ configure_file(menu.conf menu.conf COPYONLY)


add_custom_command(
OUTPUT menu.hpp menu.cpp
COMMAND stamen -n example menu.conf
COMMAND ${stamen_DIR}/../../bin/stamen -n example menu.conf
DEPENDS menu.conf
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Generating menu files"

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": "93159a6024f170bb5fedd97daad8b7dd8dbc99ab",
"packages": [ "alec", "stamen" ]
}
]
}

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

@@ -0,0 +1,23 @@

{
"name": "display",
"version-semver": "0.2.0",
"dependencies": [
{
"name": "alec",
"version>=": "0.1.17"
}
],
"default-features": [],
"features": {
"test": {
"description": "Dependencies for testing",
"dependencies": [
{
"name": "stamen",
"version>=": "1.3.0"
}
]
}
},
"builtin-baseline": "eba7c6a894fce24146af4fdf161fef8e90dd6be3"
}