Skip to content

Commit f0301e2

Browse files
committed
Update utf_view to exemplar-based INTERFACE configuration
1 parent 56d1c3f commit f0301e2

File tree

14 files changed

+128
-165
lines changed

14 files changed

+128
-165
lines changed

.github/workflows/ci_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
{ "stdlibs": ["libstdc++"],
4141
"tests": [
4242
"Debug.Default", "Release.Default", "Release.MaxSan",
43-
"Debug.Werror", "Debug.Dynamic", "Debug.Coverage",
43+
"Debug.Werror", "Debug.Coverage",
4444
"Debug.-DBEMAN_UTF_VIEW_BUILD_PAPER=ON"
4545
]
4646
}
@@ -67,7 +67,7 @@ jobs:
6767
{ "stdlibs": ["libc++"],
6868
"tests": [
6969
"Debug.Default", "Release.Default", "Release.MaxSan",
70-
"Debug.Werror", "Debug.Dynamic"
70+
"Debug.Werror"
7171
]
7272
}
7373
]

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ repos:
1111

1212
# CMake linting and formatting
1313
- repo: https://github.com/BlankSpruce/gersemi
14-
rev: 0.22.3
14+
rev: 0.24.0
1515
hooks:
1616
- id: gersemi
1717
name: CMake linting
18+
exclude: ^.*/tests/.*/data/ # Exclude test data directories
1819

1920
- repo: https://github.com/codespell-project/codespell
2021
rev: v2.4.1
2122
hooks:
2223
- id: codespell
2324

24-
exclude: 'papers/'
25+
exclude: 'papers/|infra/'

CMakeLists.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# (See accompanying file LICENSE.txt or copy at
66
# https://www.boost.org/LICENSE_1_0.txt)
77

8-
cmake_minimum_required(VERSION 3.27)
8+
cmake_minimum_required(VERSION 3.28...4.2)
99
project(
1010
beman.utf_view
1111
DESCRIPTION "C++29 UTF Transcoding Views"
@@ -33,15 +33,29 @@ option(
3333
OFF
3434
)
3535

36-
option(
37-
BEMAN_UTF_VIEW_INSTALL_CONFIG_FILE_PACKAGE
38-
"Enable creating and installing a CMake config-file package. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }."
39-
${PROJECT_IS_TOP_LEVEL}
36+
# for find of beman-install-library
37+
include(infra/cmake/beman-install-library-config.cmake)
38+
39+
add_library(beman.utf_view INTERFACE)
40+
add_library(beman::utf_view ALIAS beman.utf_view)
41+
42+
target_sources(
43+
beman.utf_view
44+
PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include"
4045
)
4146

47+
set_target_properties(beman.utf_view PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)
48+
49+
add_subdirectory(include/beman/utf_view)
50+
51+
include(CTest)
52+
53+
find_package(beman-install-library REQUIRED)
54+
beman_install_library(beman.utf_view)
55+
4256
find_package(beman::transform_view REQUIRED)
4357

44-
add_subdirectory(src/beman/utf_view)
58+
target_link_libraries(beman.utf_view INTERFACE beman::transform_view)
4559

4660
if(BEMAN_UTF_VIEW_BUILD_TESTS)
4761
enable_testing()

README.md

Lines changed: 88 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Distributed under the Boost Software License, Version 1.0.
2020

2121
**Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#under-development-and-not-yet-ready-for-production-use)
2222

23+
## License
24+
25+
beman.utf_view is licensed under BSL 1.0.
26+
2327
## Examples
2428

2529
Transcoding a UTF-8 string literal to a `std::u32string`:
@@ -144,44 +148,70 @@ Note: Building with Clang and libstdc++ is not currently supported due to variou
144148
This project supports [GitHub Codespace](https://github.com/features/codespaces)
145149
via [Development Containers](https://containers.dev/),
146150
which allows rapid development and instant hacking in your browser.
147-
We recommend you using GitHub codespace to explore this project as this
151+
We recommend using GitHub codespace to explore this project as it
148152
requires minimal setup.
149153

150-
You can create a codespace for this project by clicking this badge:
154+
Click the following badge to create a codespace:
151155

152156
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/bemanproject/utf_view)
153157

154-
For more detailed documentation regarding creating and developing inside of
155-
GitHub codespaces, please reference [this doc](https://docs.github.com/en/codespaces/).
158+
For more documentation on GitHub codespaces, please see
159+
[this doc](https://docs.github.com/en/codespaces/).
156160

157161
> [!NOTE]
158162
>
159-
> The codespace container may take up to 5 minutes to build and spin-up,
160-
> this is normal as we need to build a custom docker container to setup
161-
> an environment appropriate for beman projects.
163+
> The codespace container may take up to 5 minutes to build and spin-up; this is normal.
162164
163165
### Develop locally on your machines
164166

165167
<details>
166-
<summary> For Linux based systems </summary>
168+
<summary> For Linux </summary>
167169

168170
Beman libraries require [recent versions of CMake](#build-environment),
169-
we advise you to download CMake directly from [CMake's website](https://cmake.org/download/)
170-
or install it via the [Kitware apt library](https://apt.kitware.com/).
171+
we recommend downloading CMake directly from [CMake's website](https://cmake.org/download/)
172+
or installing it with the [Kitware apt library](https://apt.kitware.com/).
171173

172174
A [supported compiler](#supported-platforms) should be available from your package manager.
173-
Alternatively you could use an install script from official compiler vendors.
174175

175-
Here is an example of how to install the latest stable version of clang
176-
as per [the official LLVM install guide](https://apt.llvm.org/).
176+
</details>
177+
178+
<details>
179+
<summary> For MacOS </summary>
180+
181+
Beman libraries require [recent versions of CMake](#build-environment).
182+
Use [`Homebrew`](https://brew.sh/) to install the latest version of CMake.
177183

178184
```bash
179-
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
185+
brew install cmake
180186
```
181187

182-
The precise command and package name will vary depending on the Linux OS you are
183-
using. Be sure to consult documentation and the package repository for the system
184-
you are using.
188+
A [supported compiler](#supported-platforms) is also available from brew.
189+
190+
For example, you can install the latest major release of Clang as:
191+
192+
```bash
193+
brew install llvm
194+
```
195+
196+
</details>
197+
198+
<details>
199+
<summary> For Windows </summary>
200+
201+
To build Beman libraries, you will need the MSVC compiler. MSVC can be obtained
202+
by installing Visual Studio; the free Visual Studio 2022 Community Edition can
203+
be downloaded from
204+
[Microsoft](https://visualstudio.microsoft.com/vs/community/).
205+
206+
After Visual Studio has been installed, you can launch "Developer PowerShell for
207+
VS 2022" by typing it into Windows search bar. This shell environment will
208+
provide CMake, Ninja, and MSVC, allowing you to build the library and run the
209+
tests.
210+
211+
Note that you will need to use FetchContent to build GoogleTest. To do so,
212+
please see the instructions in the "Build GoogleTest dependency from github.com"
213+
dropdown in the [Project specific configure
214+
arguments](#project-specific-configure-arguments) section.
185215

186216
</details>
187217

@@ -201,28 +231,31 @@ cmake --workflow --preset gcc-debug
201231
Generally, there are two kinds of presets, `debug` and `release`.
202232

203233
The `debug` presets are designed to aid development, so it has debugging
204-
instrumentation enabled and as many sanitizers turned on as possible.
234+
instrumentation enabled and many sanitizers enabled.
205235

206236
> [!NOTE]
207237
>
208-
> The set of sanitizer supports are different across compilers.
209-
> You can checkout the exact set of compiler arguments by looking at the toolchain
210-
> files under the [`cmake`](cmake/) directory.
238+
> The sanitizers that are enabled vary from compiler to compiler.
239+
> See the toolchain files under ([`cmake`](cmake/)) to determine the exact configuration used for each preset.
211240
212-
The `release` presets are designed for use in production environments,
213-
thus they have the highest optimization turned on (e.g. `O3`).
241+
The `release` presets are designed for production use, and
242+
consequently have the highest optimization turned on (e.g. `O3`).
214243

215244
### Configure and Build Manually
216245

217-
While [CMake Presets](#configure-and-build-the-project-using-cmake-presets) are
218-
convenient, you might want to set different configuration or compiler arguments
219-
than any provided preset supports.
246+
If the presets are not suitable for your use-case, a traditional CMake
247+
invocation will provide more configurability.
220248

221249
To configure, build and test the project with extra arguments,
222250
you can run this set of commands.
223251

224252
```bash
225-
cmake -B build -S . -DCMAKE_CXX_STANDARD=23 # Your extra arguments here.
253+
cmake \
254+
-B build \
255+
-S . \
256+
-DCMAKE_CXX_STANDARD=20 \
257+
-DCMAKE_PREFIX_PATH=$PWD/infra/cmake \
258+
# Your extra arguments here.
226259
cmake --build build
227260
ctest --test-dir build
228261
```
@@ -237,14 +270,11 @@ ctest --test-dir build
237270
238271
### Project specific configure arguments
239272

240-
When configuring the project manually,
241-
you can pass an array of project specific CMake configs to customize your build.
242-
243-
Project specific options are prefixed with `BEMAN_UTF_VIEW`.
273+
Project-specific options are prefixed with `BEMAN_UTF_VIEW`.
244274
You can see the list of available options with:
245275

246276
```bash
247-
cmake -LH | grep "BEMAN_UTF_VIEW" -C 2
277+
cmake -LH -S . -B build | grep "BEMAN_UTF_VIEW" -C 2
248278
```
249279

250280
<details>
@@ -254,7 +284,7 @@ cmake -LH | grep "BEMAN_UTF_VIEW" -C 2
254284
#### `BEMAN_UTF_VIEW_BUILD_TESTS`
255285

256286
Enable building tests and test infrastructure. Default: ON.
257-
Values: { ON, OFF }.
287+
Values: `{ ON, OFF }`.
258288

259289
You can configure the project to have this option turned off via:
260290

@@ -266,6 +296,14 @@ cmake -B build -S . -DCMAKE_CXX_STANDARD=20 -DBEMAN_UTF_VIEW_BUILD_TESTS=OFF
266296

267297
Enable building examples. Default: ON. Values: { ON, OFF }.
268298

299+
#### `BEMAN_UTF_VIEW_INSTALL_CONFIG_FILE_PACKAGE`
300+
301+
Enable installing the CMake config file package. Default: ON.
302+
Values: { ON, OFF }.
303+
304+
This is required so that users of `beman.utf_view` can use
305+
`find_package(beman.utf_view)` to locate the library.
306+
269307
#### `BEMAN_UTF_VIEW_BUILD_PAPER`
270308

271309
Enable building the HTML version of P2728 and P3705 from their markdown sources. Default: ON. Values: { ON, OFF }.
@@ -283,14 +321,14 @@ include an appropriate `beman.utf_view` header from your source code.
283321

284322
> [!NOTE]
285323
>
286-
> `beman.utf_view` headers are to be included with the `beman/utf_view/` directories prefixed.
287-
> It is not supported to alter include search paths to spell the include target another way. For instance,
288-
> `#include <utf_view.hpp>` is not a supported interface.
324+
> `beman.utf_view` headers are to be included with the `beman/utf_view/` prefix.
325+
> Altering include search paths to spell the include target another way (e.g.
326+
> `#include <utf_view.hpp>`) is unsupported.
289327
290-
How you will link your project against `beman.utf_view` will depend on your build system.
291-
CMake instructions are provided in following sections.
328+
The process for incorporating `beman.utf_view` into your project depends on the
329+
build system being used. Instructions for CMake are provided in following sections.
292330

293-
### Linking your project to beman.utf_view with CMake
331+
### Incorporating `beman.utf_view` into your project with CMake
294332

295333
For CMake based projects,
296334
you will need to use the `beman.utf_view` CMake module
@@ -301,33 +339,36 @@ find_package(beman.utf_view REQUIRED)
301339
```
302340

303341
You will also need to add `beman::utf_view` to the link libraries of
304-
any libraries or executables that include beman.utf_view's header file.
342+
any libraries or executables that include `beman.utf_view` headers.
305343

306344
```cmake
307345
target_link_libraries(yourlib PUBLIC beman::utf_view)
308346
```
309347

310-
### Produce beman.utf_view static library locally
348+
### Produce beman.utf_view interface library
311349

312-
You can include utf_view's headers locally
313-
by producing a static `libbeman.utf_view.a` library.
350+
You can produce utf_view's interface library locally by:
314351

315352
```bash
316353
cmake --workflow --preset gcc-release
317-
cmake --install build/gcc-release --prefix /opt/beman.utf_view
354+
cmake --install build/gcc-release --prefix /opt/beman
318355
```
319356

320-
This will generate such directory structure at `/opt/beman.utf_view`.
357+
This will generate the following directory structure at `/opt/beman`.
321358

322359
```txt
323-
/opt/beman.utf_view
360+
/opt/beman
324361
├── include
325362
│ └── beman
326363
│ └── utf_view
327364
│ ├── // ...
328365
│ └── utf_view.hpp
329366
└── lib
330-
└── libbeman.utf_view.a
367+
└── cmake
368+
└── beman.utf_view
369+
├── beman.utf_view-config-version.cmake
370+
├── beman.utf_view-config.cmake
371+
└── beman.utf_view-targets.cmake
331372
```
332373

333374
## Paper
@@ -344,7 +385,3 @@ beman.utf_view is based on P2728 and P3705.
344385
## Authors
345386

346387
The implementation of P2728 is a fork by Eddie Nolan of the implementation of P2728R6 in libstdc++ by Jonathan Wakely at [`gcc/libstdc++-v3/include/bits/unicode.h`](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/bits/unicode.h;h=66f8399fdfb05d85fcdb37fa9ec7c4089feb7a7d;hb=37a4c5c23a27).
347-
348-
## License
349-
350-
beman.utf_view is licensed under BSL 1.0.
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: BSL-1.0
2+
3+
target_sources(beman.utf_view PUBLIC FILE_SET HEADERS FILES
4+
code_unit_view.hpp
5+
detail/concepts.hpp
6+
detail/constexpr_unless_msvc.hpp
7+
detail/fake_inplace_vector.hpp
8+
detail/nontype_t_polyfill.hpp
9+
null_term.hpp
10+
to_utf_view.hpp
11+
utf_view.hpp
12+
)

infra/.beman_submodule

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[beman_submodule]
22
remote=https://github.com/bemanproject/infra.git
3-
commit_hash=bb58b2a1cc894d58a55bf745be78f5d27029e245
3+
commit_hash=9f89e813b844915267b783289d386a09c69560d1

infra/.pre-commit-config.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,3 @@ repos:
1919
- id: gersemi
2020
name: CMake linting
2121
exclude: ^.*/tests/.*/data/ # Exclude test data directories
22-
23-
# Python linting and formatting
24-
# config file: ruff.toml (not currently present but add if needed)
25-
# https://docs.astral.sh/ruff/configuration/
26-
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.13.2
28-
hooks:
29-
- id: ruff-check
30-
files: ^tools/beman-tidy/
31-
- id: ruff-format
32-
files: ^tools/beman-tidy/

infra/.pre-commit-hooks.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)