Skip to content

Commit c5032f7

Browse files
committed
docs: readme formatting
1 parent bf33860 commit c5032f7

1 file changed

Lines changed: 34 additions & 29 deletions

File tree

README.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
2727
# run_vcpkg()
2828
2929
# Set the project name and language
30-
project(myproject LANGUAGES CXX)
30+
project(myproject LANGUAGES CXX C)
3131
3232
# Initialize project_options variable related to this project
3333
# This overwrites `project_options` and sets `project_warnings`
@@ -36,25 +36,27 @@ project_options(
3636
ENABLE_CACHE
3737
ENABLE_CPPCHECK
3838
ENABLE_CLANG_TIDY
39-
# WARNINGS_AS_ERRORS
4039
# ENABLE_CONAN
4140
# ENABLE_IPO
42-
# ENABLE_INCLUDE_WHAT_YOU_USE
43-
# ENABLE_COVERAGE
44-
# ENABLE_PCH
45-
# PCH_HEADERS
4641
# ENABLE_DOXYGEN
47-
# ENABLE_USER_LINKER
48-
# ENABLE_BUILD_WITH_TIME_TRACE
49-
# ENABLE_UNITY
42+
# ENABLE_COVERAGE
43+
# WARNINGS_AS_ERRORS
5044
# ENABLE_SANITIZER_ADDRESS
5145
# ENABLE_SANITIZER_LEAK
5246
# ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
5347
# ENABLE_SANITIZER_THREAD
5448
# ENABLE_SANITIZER_MEMORY
49+
# ENABLE_INCLUDE_WHAT_YOU_USE
50+
# ENABLE_PCH
51+
# PCH_HEADERS
52+
# ENABLE_USER_LINKER
53+
# ENABLE_BUILD_WITH_TIME_TRACE
54+
# ENABLE_UNITY
5555
# CONAN_OPTIONS
5656
)
57+
```
5758

59+
```cmake
5860
# add your executables, libraries, etc. here:
5961
6062
add_executable(myprogram main.cpp)
@@ -74,24 +76,24 @@ target_link_system_libraries(
7476

7577
It accepts the following named flags:
7678

77-
- `WARNINGS_AS_ERRORS`: Treat the warnings as errors
79+
- `ENABLE_CACHE`: Enable cache if available
7880
- `ENABLE_CPPCHECK`: Enable static analysis with Cppcheck
7981
- `ENABLE_CLANG_TIDY`: Enable static analysis with clang-tidy
82+
- `ENABLE_CONAN`: Use Conan for dependency management
8083
- `ENABLE_IPO`: Enable Interprocedural Optimization (Link Time Optimization, LTO) in the release build
81-
- `ENABLE_INCLUDE_WHAT_YOU_USE`: Enable static analysis with include-what-you-use
8284
- `ENABLE_COVERAGE`: Enable coverage reporting for gcc/clang
83-
- `ENABLE_CACHE`: Enable cache if available
84-
- `ENABLE_PCH`: Enable Precompiled Headers
85-
- `ENABLE_CONAN`: Use Conan for dependency management
8685
- `ENABLE_DOXYGEN`: Enable Doxygen doc builds of source
87-
- `ENABLE_USER_LINKER`: Enable a specific linker if available
88-
- `ENABLE_BUILD_WITH_TIME_TRACE`: Enable `-ftime-trace` to generate time tracing `.json` files on clang
89-
- `ENABLE_UNITY`: Enable Unity builds of projects
86+
- `WARNINGS_AS_ERRORS`: Treat the warnings as errors
9087
- `ENABLE_SANITIZER_ADDRESS`: Enable address sanitizer
9188
- `ENABLE_SANITIZER_LEAK`: Enable leak sanitizer
9289
- `ENABLE_SANITIZER_UNDEFINED_BEHAVIOR`: Enable undefined behavior sanitizer
9390
- `ENABLE_SANITIZER_THREAD`: Enable thread sanitizer
9491
- `ENABLE_SANITIZER_MEMORY`: Enable memory sanitizer
92+
- `ENABLE_PCH`: Enable Precompiled Headers
93+
- `ENABLE_INCLUDE_WHAT_YOU_USE`: Enable static analysis with include-what-you-use
94+
- `ENABLE_USER_LINKER`: Enable a specific linker if available
95+
- `ENABLE_BUILD_WITH_TIME_TRACE`: Enable `-ftime-trace` to generate time tracing `.json` files on clang
96+
- `ENABLE_UNITY`: Enable Unity builds of projects
9597

9698
It gets the following named parameters that can have different values in front of them:
9799

@@ -113,7 +115,7 @@ Named String:
113115
- `VCPKG_DIR`: (Defaults to `~/vcpkg`). You can provide the vcpkg installation directory using this optional parameter.
114116
If the directory does not exist, it will automatically install vcpkg in this directory.
115117

116-
- `VCPKG_URL`: (Defaults to `https://github.com/microsoft/vcpkg.git`). This option allows setting URL of the vcpkg repository. By default, the official vcpkg repository is used.
118+
- `VCPKG_URL`: (Defaults to `https://github.com/microsoft/vcpkg.git`). This option allows setting the URL of the vcpkg repository. By default, the official vcpkg repository is used.
117119

118120
## `target_link_system_libraries` function
119121

@@ -123,28 +125,28 @@ A very useful function that accepts the same arguments as `target_link_libraries
123125

124126
Similar to `target_include_directories`, but it suppresses the warnings. It is useful if you want to include some external directories directly.
125127

126-
## Changing the project_options parameters dynamically
128+
## Changing the project_options dynamically
127129

128-
It might be useful to change the test and development options on the fly (e.g., to enable sanitizers when running tests). To do this, you can include the `DynamicOptions.cmake`, which adds `dynamic_project_options`. `dynamic_project_options` provides a recommended set of defaults (all static analysis and runtime analysis enabled for platforms where that is possible) while also providing a high level option `ENABLE_DEVELOPER_MODE` (defaulted to `ON`) which can be turned off for easy use by non-developers.
130+
During the test and development, it can be useful to change options on the fly. For example, to enable sanitizers when running tests. You can include `DynamicOptions.cmake`, which imports the `dynamic_project_options` function.
129131

130-
The goal of the `dynamic_project_options` is to give a safe and well analyzed environment to the developer by default, while simultaneously making it easy for a user of the project to compile while not having to worry about clang-tidy, sanitizers, cppcheck, etc.
132+
`dynamic_project_options` provides a recommended set of defaults (all static analysis and runtime analysis enabled for platforms where that is possible) while also providing a high-level option `ENABLE_DEVELOPER_MODE` (defaulted to `ON`) which can be turned off for easy use by non-developers.
133+
134+
The goal of the `dynamic_project_options` is to give a safe and well-analyzed environment to the developer by default while simultaneously making it easy for a user of the project to compile while not having to worry about clang-tidy, sanitizers, cppcheck, etc.
131135

132136
The defaults presented to the user can be modified with
133137

134-
* `set(<featurename>_DEFAULT value)` - for user and developer builds
135-
* `set(<featurename>_USER_DEFAULT value)` - for user builds
136-
* `set(<featureoptionname>_DEVELOPER_DEFAULT value)` - for developer builds
138+
- `set(<featurename>_DEFAULT value)` - for user and developer builds
139+
- `set(<featurename>_USER_DEFAULT value)` - for user builds
140+
- `set(<featureoptionname>_DEVELOPER_DEFAULT value)` - for developer builds
137141

138142
If you need to fix a setting for the sake of a command-line configuration, you can use:
139143

140-
```
144+
```shell
141145
cmake -DOPT_<featurename>:BOOL=value
142146
```
143147

144-
145-
146148
<details>
147-
<summary>Click to show the example:</summary>
149+
<summary> 👉 Click to show the example:</summary>
148150

149151
```cmake
150152
cmake_minimum_required(VERSION 3.16)
@@ -170,7 +172,7 @@ include(${_project_options_SOURCE_DIR}/src/DynamicOptions.cmake)
170172
# run_vcpkg()
171173
172174
# Set the project name and language
173-
project(myproject LANGUAGES CXX)
175+
project(myproject LANGUAGES CXX C)
174176
175177
# Set PCH to be on by default for all non-Developer Mode Builds
176178
# (this is just intended as an example of what is possible)
@@ -183,6 +185,9 @@ dynamic_project_options(
183185
# set PCH headers you want enabled. Format can be slow, so this might be helpful
184186
PCH_HEADERS <vector> <string> <fmt/format.h>
185187
)
188+
```
189+
190+
```cmake
186191
# add your executables, libraries, etc. here:
187192
188193
add_executable(myprogram main.cpp)

0 commit comments

Comments
 (0)