Skip to content

Commit be38714

Browse files
committed
Add a 'Compiler flags' example to the documentation
1 parent 09ded38 commit be38714

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

docs/examples/compile-options.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# Automatically generated from tests/compile-options/cmake.toml - DO NOT EDIT
3+
layout: default
4+
title: Compiler flags
5+
permalink: /examples/compile-options
6+
parent: Examples
7+
nav_order: 9
8+
---
9+
10+
# Compiler flags
11+
12+
Example project that sets compiler/linker flags for various platforms.
13+
14+
```toml
15+
[project]
16+
name = "compile-options"
17+
description = "Compiler flags"
18+
19+
[target.hello]
20+
type = "executable"
21+
sources = ["src/main.cpp"]
22+
msvc.compile-options = ["/W2"]
23+
gcc.compile-options = ["-Wall"]
24+
clang.compile-options = ["-Wall"]
25+
```
26+
27+
The `hello` target uses [conditions](/cmake-toml#conditions) to set different compiler flags depending on the platform. See the [targets](/cmake-toml/#targets) documentation for other things you can set.
28+
29+
_Note_: In general you only want to specify flags _required_ to compile your code without errors.
30+
31+
<sup><sub>This page was automatically generated from [tests/compile-options/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/compile-options/cmake.toml).</sub></sup>

tests/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/cmake.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ name = "msvc-runtime"
5252
working-directory = "msvc-runtime"
5353
command = "$<TARGET_FILE:cmkr>"
5454
arguments = ["build"]
55+
56+
[[test]]
57+
name = "compile-options"
58+
working-directory = "compile-options"
59+
command = "$<TARGET_FILE:cmkr>"
60+
arguments = ["build"]

tests/compile-options/cmake.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Example project that sets compiler/linker flags for various platforms.
2+
3+
[project]
4+
name = "compile-options"
5+
description = "Compiler flags"
6+
7+
[target.hello]
8+
type = "executable"
9+
sources = ["src/main.cpp"]
10+
msvc.compile-options = ["/W2"]
11+
gcc.compile-options = ["-Wall"]
12+
clang.compile-options = ["-Wall"]
13+
14+
# The `hello` target uses [conditions](/cmake-toml#conditions) to set different compiler flags depending on the platform. See the [targets](/cmake-toml/#targets) documentation for other things you can set.
15+
# _Note_: In general you only want to specify flags _required_ to compile your code without errors.

tests/compile-options/src/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <cstdio>
2+
3+
int main() {
4+
puts("Hello from cmkr!");
5+
}

0 commit comments

Comments
 (0)