Skip to content

Commit 3905061

Browse files
committed
Addd build instructions
1 parent 49dd45a commit 3905061

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ This repository implements `std::optional` extensions targeting C++26. The `Bema
1313
* [Give *std::optional* Range Support (P3168R2)](https://wg21.link/P3168R2)
1414
* [`std::optional<T&>` (P2988R5)](https://wg21.link/P2988R5)
1515

16+
17+
## Table of Contents
18+
19+
- [Beman.Optional26: C++26 Extensions for std::optional](#bemanoptional26-c26-extensions-for-stdoptional)
20+
- [Table of Contents](#table-of-contents)
21+
- [License](#license)
22+
- [Examples](#examples)
23+
- [range\_loop](#range_loop)
24+
- [optional\_ref](#optional_ref)
25+
- [How to Build](#how-to-build)
26+
- [Compiler Support](#compiler-support)
27+
- [Dependencies](#dependencies)
28+
- [Instructions](#instructions)
29+
- [Default Build and Test Flow](#default-build-and-test-flow)
30+
- [More Complex Cases](#more-complex-cases)
31+
- [Step by Step Build: Build and Run Tests](#step-by-step-build-build-and-run-tests)
32+
- [Step by Step Build: Build Production and Skip Tests](#step-by-step-build-build-production-and-skip-tests)
33+
- [Papers](#papers)
34+
35+
1636
## License
1737

1838
Source is licensed with the Apache 2.0 license with LLVM exceptions
@@ -123,7 +143,7 @@ apt-get install \
123143

124144
Full set of supported toolchains can be found in [.github/workflows/ci.yml](.github/workflows/ci.yml).
125145

126-
#### Basic Build
146+
#### Default Build and Test Flow
127147

128148
This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will work, producing a static `beman_optional26` library, ready to package:
129149

@@ -168,7 +188,7 @@ Total Test time (real) = 0.09 sec
168188

169189
This should build and run the tests with GCC 14 with the address and undefined behavior sanitizers enabled.
170190

171-
#### More complex cases
191+
#### More Complex Cases
172192

173193
The CMake preset system suffers from combinitorial explosion. There is a makefile in the root of the repository to aid in running more configurations.
174194

@@ -178,6 +198,63 @@ make -k TOOLCHAIN=clang-18 CONFIG=Tsan VERBOSE=1
178198

179199
The makefile will use your system compiler, `c++`, if no toolchain name is provided, otherwise it will use the toolchain in the etc/ directory to perform the build. The Ninja multi config generator is used, with configurations for `RelWithDebugInfo`, `Debug`, `Tsan`, and `Asan` configured by default.
180200

201+
#### Step by Step Build: Build and Run Tests
202+
203+
CI current build and test flows:
204+
205+
```shell
206+
# Configure build: default build production code + tests (BUILD_TESTING=ON by default).
207+
$ rm -rf .build/
208+
$ mkdir -p .build
209+
$ cd .build
210+
$ cmake -G "Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake -B . -S ..
211+
-- The CXX compiler identification is Clang 19.0.0
212+
...
213+
-- Build files have been written to: /home/dariusn/git/Beman/Beman.Optional26/.build
214+
215+
# Build.
216+
$ cd ..
217+
$ cmake --build .build --config Asan --target all -- -k 0
218+
...
219+
[30/30] Linking CXX executable examples/Asan/sample
220+
221+
# Run tests.
222+
$ cd .build
223+
$ ctest --build-config Asan --output-on-failure
224+
Test project /home/dariusn/git/Beman/Beman.Optional26/.build
225+
...
226+
100% tests passed, 0 tests failed out of 82
227+
228+
Total Test time (real) = 0.67 sec
229+
```
230+
231+
#### Step by Step Build: Build Production and Skip Tests
232+
233+
By default, we build and run tests. You can provide `-DBUILD_TESTING=OFF` and completely disable building tests:
234+
235+
```shell
236+
# Configure build: build production code, skip tests (BUILD_TESTING=OFF).
237+
$ rm -rf .build/
238+
$ mkdir -p .build
239+
$ cd .build
240+
$ cmake -G "Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake -DBUILD_TESTING=OFF -B . -S ..
241+
-- The CXX compiler identification is Clang 19.0.0
242+
...
243+
-- Build files have been written to: /home/dariusn/git/Beman/Beman.Optional26/.build
244+
245+
# Build.
246+
$ cd ..
247+
$ cmake --build .build --config Asan --target all -- -k 0
248+
...
249+
[15/15] Linking CXX executable examples/Asan/sample
250+
251+
# Check that tests are not built/installed.
252+
$ cd .build
253+
$ ctest --build-config Asan --output-on-failure
254+
Test project /home/dariusn/git/Beman/Beman.Optional26/.build
255+
No tests were found!!!
256+
```
257+
181258
## Papers
182259

183260
Latest revision(s) of the papers can be built / found at:

0 commit comments

Comments
 (0)