Skip to content

Commit 87db22f

Browse files
committed
Add documentation for the cmake.toml format
1 parent 416a836 commit 87db22f

File tree

6 files changed

+178
-4
lines changed

6 files changed

+178
-4
lines changed

docs/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_site/
2-
.jekyll-metadata
2+
.jekyll-metadata

docs/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ end
1111

1212
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
1313
gem "just-the-docs"
14+
15+
gem "webrick", "~> 1.7"

docs/Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ GEM
262262
unf_ext
263263
unf_ext (0.0.7.7)
264264
unicode-display_width (1.7.0)
265+
webrick (1.7.0)
265266
zeitwerk (2.4.2)
266267

267268
PLATFORMS
@@ -275,6 +276,7 @@ DEPENDENCIES
275276
tzinfo (~> 1.2)
276277
tzinfo-data
277278
wdm (~> 0.1.1)
279+
webrick (~> 1.7)
278280

279281
BUNDLED WITH
280-
2.1.2
282+
2.2.26

docs/cmake-toml.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
layout: page
3+
title: cmake.toml
4+
permalink: /cmake-toml/
5+
nav_order: 3
6+
---
7+
8+
# cmake.toml
9+
10+
This page is supposed to be a reference for the options in the `cmake.toml` file. If you think anything is missing or unclear, please [edit this page](https://github.com/build-cpp/cmkr/edit/main/docs/cmake-toml.md) or open an [issue](https://github.com/build-cpp/cmkr/issues).
11+
12+
See the [examples](/examples) section for more real-world examples.
13+
14+
## CMake configuration
15+
16+
```toml
17+
[cmake]
18+
version = "3.15"
19+
cmkr-include = "cmkr.cmake"
20+
```
21+
22+
## Project configuration
23+
24+
```toml
25+
[project]
26+
name = "myproject"
27+
version = "1.0.0"
28+
description = "Description of the project"
29+
languages = ["C", "CXX"]
30+
cmake-before = """
31+
message(STATUS "CMake injected before the project() call")
32+
"""
33+
cmake-after = """
34+
message(STATUS "CMake injected after the project() call")
35+
"""
36+
include-before = ["cmake/before-project.cmake"]
37+
include-after = ["cmake/after-project.cmake"]
38+
```
39+
40+
## Conditions
41+
42+
```toml
43+
[conditions]
44+
arch64 = "CMAKE_SIZEOF_VOID_P EQUALS 8"
45+
arch32 = "CMAKE_SIZEOF_VOID_P EQUALS 4"
46+
```
47+
48+
## Subdirectories
49+
50+
```toml
51+
[subdir.mysubdir]
52+
condition = "linux"
53+
cmake-before = """
54+
message(STATUS "CMake injected before the add_subdirectory() call"
55+
"""
56+
cmake-after = """
57+
message(STATUS "CMake injected after the add_subdirectory() call")
58+
"""
59+
include-before = ["cmake/before-subdir.cmake"]
60+
include-after = ["cmake/after-subdir.cmake"]
61+
```
62+
63+
## Vcpkg
64+
65+
```toml
66+
[vcpkg]
67+
version = "2021.05.12"
68+
url = "https://github.com/microsoft/vcpkg/archive/refs/tags/2021.05.12.tar.gz"
69+
packages = ["fmt", "zlib"]
70+
```
71+
72+
The vcpkg `version` will automatically generate the `url` from the official repository. For a custom registry you can specify your own `url` (and omit the `version`).
73+
74+
## Packages
75+
76+
```toml
77+
[find-package]
78+
mypackage = { version = "1.0", required = true, config = true, components = ["mycomponent"] }
79+
80+
# Alternative syntax
81+
[find-package.mypackage]
82+
version = "1.0"
83+
required = true
84+
config = true
85+
components = ["mycomponent"]
86+
```
87+
88+
## FetchContent
89+
90+
**Note**: The `[fetch-content]` feature is unpolished and will likely change in a future release.
91+
92+
```toml
93+
[fetch-content]
94+
gitcontent = { git = "https://github.com/myuser/gitcontent", tag = "v0.1" }
95+
svncontent = { svn = "https://svn-host.com/url", rev = "svn_rev" }
96+
urlcontent = { url = "https://content-host.com/urlcontent.zip", hash = "123123123123" }
97+
98+
# Alternative syntax
99+
[fetch-content.gitcontent]
100+
git = "https://github.com/myuser/gitcontent"
101+
tag = "v0.1"
102+
```
103+
104+
## Targets
105+
106+
```toml
107+
[target.mytarget]
108+
condition = "linux"
109+
alias = "mytarget::mytarget"
110+
type = "static" # executable, library, shared, static, interface, custom
111+
headers = ["src/mytarget.h"]
112+
sources = ["src/mytarget.cpp"]
113+
114+
# The keys below match the target_xxx CMake commands
115+
# Keys prefixed with private- will get PRIVATE visibility
116+
compile-definitions = [""]
117+
private-compile-definitions = [""]
118+
compile-features = [""]
119+
private-compile-features = [""]
120+
compile-options = [""]
121+
private-compile-options = [""]
122+
include-directories = [""]
123+
private-include-directories = [""]
124+
link-directories = [""]
125+
private-link-directories = [""]
126+
link-libraries = [""]
127+
private-link-libraries = [""]
128+
link-options = [""]
129+
private-link-options = [""]
130+
precompile-headers = [""]
131+
private-precompile-headers = [""]
132+
133+
cmake-before = """
134+
message(STATUS "CMake injected before the target")
135+
"""
136+
cmake-after = """
137+
message(STATUS "CMake injected after the target")
138+
"""
139+
include-before = "cmake/target-before.cmake"
140+
include-after = "cmake/target-after.cmake"
141+
142+
# See https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets for a list of target properties
143+
[target.mytarget.properties]
144+
CXX_STANDARD = 17
145+
CXX_STANDARD_REQUIRED = true
146+
FOLDER = "MyFolder"
147+
```
148+
149+
## Tests and installation (unfinished)
150+
151+
**Note**: The `[[test]]` and `[[install]]` are unfinished features and will likely change in a future release.
152+
153+
```toml
154+
# You can declare as many as you want like this, but the name has to be unique
155+
[[test]]
156+
name = "mytest"
157+
command = "$<TARGET_FILE:mytest>"
158+
arguments = ["arg1", "arg2"]
159+
configurations = ["Debug", "Release", "RelWithDebInfo", "MinSizeRelease"]
160+
working-directory = "mytest-dir"
161+
```
162+
163+
```toml
164+
[[install]]
165+
targets = ["mytarget", "mytest"]
166+
destination = ["bin"]
167+
files = ["content/my.png"]
168+
dirs = [""]
169+
configs = [""]
170+
```

docs/command-line.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ permalink: /command-line/
55
nav_order: 2
66
---
77

8-
## Command line
8+
# Command line
99

1010
Optionally you can install `cmkr` in your `PATH` and use it as a utility from the command line:
1111

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ permalink: /getting-started/
55
nav_order: 1
66
---
77

8-
## Getting started
8+
# Getting started
99

1010
The easiest way to get started is to use the [cmkr_for_beginners](https://github.com/build-cpp/cmkr_for_beginners) template repository. Either open it in [Gitpod](https://gitpod.io/#https://github.com/build-cpp/cmkr_for_beginners), or clone the repository and run:
1111

0 commit comments

Comments
 (0)