Skip to content

Commit bdcfeb9

Browse files
authored
Merge pull request #724 from sebproell/list-cmake-vars
List all our CMake variables in the documentation
2 parents 3b79bdf + 9673ed2 commit bdcfeb9

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

doc/documentation/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ if(FOUR_C_BUILD_DOCUMENTATION)
4141
COMMAND
4242
cmake ${PROJECT_SOURCE_DIR} --list-presets >
4343
${_sphinx_OUT_DIR}/reference_docs/4C-cmake-presets.txt
44+
COMMAND
45+
bash ${CMAKE_CURRENT_SOURCE_DIR}/scripts/extract_cmake_variables.sh
46+
${PROJECT_BINARY_DIR}/CMakeCache.txt >
47+
${_sphinx_OUT_DIR}/reference_docs/4C-cmake-variables.csv
4448
COMMAND
4549
${SPHINX_EXECUTABLE} -W -n -q -b html # warnings are errors and be nit-picky
4650
-i "${CMAKE_CURRENT_SOURCE_DIR}/src" -i "${_sphinx_OUT_DIR}/reference_docs" -i
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# This file is part of 4C multiphysics licensed under the
4+
# GNU Lesser General Public License v3.0 or later.
5+
#
6+
# See the LICENSE.md file in the top-level for license information.
7+
#
8+
# SPDX-License-Identifier: LGPL-3.0-or-later
9+
10+
# This script extracts CMake variables from the CMakeCache.txt file.
11+
CACHE_FILE=$1
12+
13+
awk '
14+
BEGIN {
15+
print "Variable,Type,Description"
16+
doc = ""
17+
}
18+
/^\/\// {
19+
line = $0
20+
gsub("^//", "", line)
21+
gsub(/^[ \t]+|[ \t]+$/, "", line)
22+
doc = (doc == "") ? line : doc " " line
23+
next
24+
}
25+
/^[^#].*:/ {
26+
split($0, a, ":")
27+
name = a[1]
28+
split(a[2], t, "=")
29+
type = t[1]
30+
if (name ~ /^FOUR_C/ && type != "INTERNAL") {
31+
gsub(/"/, "\"\"", doc)
32+
printf "\"``%s``\",\"%s\",\"%s\"\n", name, type, doc
33+
}
34+
doc = "" # reset for next block
35+
}
36+
' ${CACHE_FILE}

doc/documentation/src/developer_guide/developer_cmake.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. _cmakepresets:
1+
.. _developer_cmake:
22

3-
CMake presets
4-
--------------
3+
CMake
4+
-----
55

66
CMake presets are |FOURC|'s recommended way to configure and manage different configurations of |FOURC|.
77
This small article will go through a few of them. The experts should also read the
@@ -70,14 +70,25 @@ Don't be overwhelmed by the options you could potentially set.
7070
optimizes the build setup for iterative development cycles.
7171
- We try to detect reasonable defaults for you internally.
7272

73+
Reference of all CMake variables
74+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75+
7376
Over time you might realize that you want to turn on additional dependencies or features.
74-
To see which other options you can set, consult the console output of CMake or run `ccmake .` in the build folder.
75-
Alternatively, all options are also printed with their ``ON`` or ``OFF`` state whenever ``cmake`` runs.
77+
To see which other options you can set, consult the console output of CMake or run ``ccmake .`` in the build folder.
78+
Alternatively, many options are also printed with their ``ON`` or ``OFF`` state whenever ``cmake`` runs.
7679

77-
**Remark:** Variables either start with the prefix `FOUR_C_` indicating that this variable only affects |FOURC| itself,
78-
or they start with `CMAKE_` indicating that the variable (potentially) affects all dependent projects in a way
80+
**Remark:** Variables either start with the prefix ``FOUR_C_`` indicating that this variable only affects |FOURC| itself,
81+
or they start with ``CMAKE_`` indicating that the variable (potentially) affects all dependent projects in a way
7982
specified directly in the CMake documentation.
8083

84+
This is a list of all variables that are available to configure |FOURC|:
85+
86+
.. csv-table::
87+
:file: /4C-cmake-variables.csv
88+
:header-rows: 1
89+
:widths: 20, 20, 60
90+
91+
8192
Configuration from the IDE
8293
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8394

doc/documentation/src/installation/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ In a preset within this file, you should define a few options that are important
173173
- the build directory. It is good practice to indicate the value for ``CMAKE_BUILD_TYPE`` in the folder name, e.g. by
174174
``"binaryDir": "<4C-basedir>/builds/release-build"`` (the folder name is completely up to you).
175175

176-
More information about the cmake presets can be found :ref:`here <cmakepresets>`.
176+
More information about the cmake presets can be found :ref:`here <developer_cmake>`.
177177

178178

179179
.. note::

0 commit comments

Comments
 (0)