You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Automatically generated from tests/templates/cmake.toml - DO NOT EDIT
3
+
layout: default
4
+
title: Target templates
5
+
permalink: /examples/templates
6
+
parent: Examples
7
+
nav_order: 7
8
+
---
9
+
10
+
# Target templates
11
+
12
+
To avoid repeating yourself in targets you can create your own target type (template). All properties of the template are inherited when used as a target type.
13
+
14
+
```toml
15
+
[project]
16
+
name = "templates"
17
+
description = "Target templates"
18
+
19
+
[template.app]
20
+
type = "executable"
21
+
sources = ["src/templates.cpp"]
22
+
compile-definitions = ["IS_APP"]
23
+
24
+
# Unlike interface targets you can also inherit properties
25
+
[template.app.properties]
26
+
CXX_STANDARD = "11"
27
+
CXX_STANDARD_REQUIRED = true
28
+
29
+
[target.app-a]
30
+
type = "app"
31
+
compile-definitions = ["APP_A"]
32
+
33
+
[target.app-b]
34
+
type = "app"
35
+
compile-definitions = ["APP_B"]
36
+
```
37
+
38
+
**Note**: In most cases you probably want to use an [interface](/examples/interface) target instead.
39
+
40
+
<sup><sub>This page was automatically generated from [tests/templates/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/templates/cmake.toml).</sub></sup>
#To avoid repeating yourself in targets you can create your own target type (template). All properties of the template are inherited when used as a target type.
2
2
3
3
[project]
4
4
name = "templates"
5
-
description = "Template example"
5
+
description = "Target templates"
6
6
7
7
[template.app]
8
8
type = "executable"
9
9
sources = ["src/templates.cpp"]
10
-
compile-definitions = ["IS_APP=true"]
10
+
compile-definitions = ["IS_APP"]
11
+
12
+
# Unlike interface targets you can also inherit properties
13
+
[template.app.properties]
14
+
CXX_STANDARD = "11"
15
+
CXX_STANDARD_REQUIRED = true
11
16
12
17
[target.app-a]
13
18
type = "app"
@@ -16,3 +21,5 @@ compile-definitions = ["APP_A"]
16
21
[target.app-b]
17
22
type = "app"
18
23
compile-definitions = ["APP_B"]
24
+
25
+
# **Note**: In most cases you probably want to use an [interface](/examples/interface) target instead.
0 commit comments