Skip to content

Commit 4b300df

Browse files
committed
Add some more tests for the documentation
1 parent 760b2a8 commit 4b300df

File tree

11 files changed

+155
-2
lines changed

11 files changed

+155
-2
lines changed

docs/examples/cxx-standard.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# Automatically generated from tests/cxx-standard/cmake.toml - DO NOT EDIT
3+
layout: default
4+
title: Changing C++ standard
5+
permalink: /examples/cxx-standard
6+
parent: Examples
7+
nav_order: 5
8+
---
9+
10+
# Changing C++ standard
11+
12+
Require a C++11 compiler for the target `example`.
13+
14+
```toml
15+
[project]
16+
name = "cxx-standard"
17+
description = "Changing C++ standard"
18+
19+
[target.example]
20+
type = "executable"
21+
sources = ["src/main.cpp"]
22+
compile-features = ["cxx_std_11"]
23+
```
24+
25+
This is equivalent to CMake's [target_compile_features](https://cmake.org/cmake/help/latest/command/target_compile_features.html)`(example PRIVATE cxx_std_11)`. For more information on available C/C++ standards and features see [cmake-compile-features(7)](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html).
26+
27+
<sup><sub>This page was automatically generated from [tests/cxx-standard/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/cxx-standard/cmake.toml).</sub></sup>

docs/examples/globbing.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
# Automatically generated from tests/globbing/cmake.toml - DO NOT EDIT
3+
layout: default
4+
title: Globbing sources
5+
permalink: /examples/globbing
6+
parent: Examples
7+
nav_order: 6
8+
---
9+
10+
# Globbing sources
11+
12+
13+
14+
```toml
15+
[project]
16+
name = "globbing"
17+
description = "Globbing sources"
18+
19+
# Recursively glob in the mylib/ folder
20+
[target.mylib]
21+
type = "static"
22+
alias = "mylib::mylib"
23+
sources = ["mylib/**.hpp", "mylib/**.cpp"]
24+
include-directories = ["mylib/include"]
25+
26+
# Single-folder glob in example/src/
27+
[target.example]
28+
type = "executable"
29+
sources = ["example/src/*.cpp"]
30+
link-libraries = ["mylib::mylib"]
31+
```
32+
33+
As you can see in the example above you can use `**.ext` to glob recursively and `*.ext` to glob non-recursively. This **does not** generate `file(GLOB ...)` commands, but instead globs when cmkr is run. Files are sorted to give deterministic results regardless of the platform used.
34+
35+
<sup><sub>This page was automatically generated from [tests/globbing/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/globbing/cmake.toml).</sub></sup>

tests/CMakeLists.txt

Lines changed: 20 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: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,16 @@ arguments = ["build"]
2626
name = "vcpkg"
2727
command = "$<TARGET_FILE:cmkr>"
2828
working-directory = "vcpkg"
29-
arguments = ["build"]
29+
arguments = ["build"]
30+
31+
[[test]]
32+
name = "cxx-standard"
33+
command = "$<TARGET_FILE:cmkr>"
34+
working-directory = "cxx-standard"
35+
arguments = ["build"]
36+
37+
[[test]]
38+
name = "globbing"
39+
command = "$<TARGET_FILE:cmkr>"
40+
working-directory = "globbing"
41+
arguments = ["build"]

tests/cxx-standard/cmake.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Require a C++11 compiler for the target `example`.
2+
3+
[project]
4+
name = "cxx-standard"
5+
description = "Changing C++ standard"
6+
7+
[target.example]
8+
type = "executable"
9+
sources = ["src/main.cpp"]
10+
compile-features = ["cxx_std_11"]
11+
12+
# This is equivalent to CMake's [target_compile_features](https://cmake.org/cmake/help/latest/command/target_compile_features.html)`(example PRIVATE cxx_std_11)`. For more information on available C/C++ standards and features see [cmake-compile-features(7)](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html).

tests/cxx-standard/src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <cstdio>
2+
#include <tuple>
3+
4+
int main()
5+
{
6+
auto tpl = std::make_tuple(1, 2);
7+
printf("Hello from C++11 %d\n", std::get<0>(tpl));
8+
}

tests/globbing/cmake.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[project]
2+
name = "globbing"
3+
description = "Globbing sources"
4+
5+
# Recursively glob in the mylib/ folder
6+
[target.mylib]
7+
type = "static"
8+
alias = "mylib::mylib"
9+
sources = ["mylib/**.hpp", "mylib/**.cpp"]
10+
include-directories = ["mylib/include"]
11+
12+
# Single-folder glob in example/src/
13+
[target.example]
14+
type = "executable"
15+
sources = ["example/src/*.cpp"]
16+
link-libraries = ["mylib::mylib"]
17+
18+
# As you can see in the example above you can use `**.ext` to glob recursively and `*.ext` to glob non-recursively. This **does not** generate `file(GLOB ...)` commands, but instead globs when cmkr is run. Files are sorted to give deterministic results regardless of the platform used.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <iostream>
2+
#include <mylib/mylib.hpp>
3+
4+
int main() {
5+
std::cout << mylib::message() << std::endl;
6+
return 0;
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include <string>
4+
5+
namespace mylib
6+
{
7+
std::string message();
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <mylib/mylib.hpp>
2+
3+
std::string mylib::message()
4+
{
5+
return "cmkr is awesome!";
6+
}

0 commit comments

Comments
 (0)