Skip to content

Commit d5ea34a

Browse files
committed
Add test for conditional Objective-C support
1 parent 4772a2b commit d5ea34a

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed

docs/examples/objective-c.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# Automatically generated from tests/objective-c/cmake.toml - DO NOT EDIT
3+
layout: default
4+
title: Objective-C
5+
permalink: /examples/objective-c
6+
parent: Examples
7+
nav_order: 11
8+
---
9+
10+
# Objective-C
11+
12+
Add Objective-C sources on Apple platforms:
13+
14+
```toml
15+
[project]
16+
name = "objective-c"
17+
description = "Objective-C"
18+
apple.languages = ["OBJC"]
19+
20+
[target.hello]
21+
type = "executable"
22+
sources = ["src/main.cpp"]
23+
apple.sources = ["src/apple.m"]
24+
```
25+
26+
27+
28+
<sup><sub>This page was automatically generated from [tests/objective-c/cmake.toml](https://github.com/build-cpp/cmkr/tree/main/tests/objective-c/cmake.toml).</sub></sup>

tests/CMakeLists.txt

Lines changed: 9 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
@@ -65,3 +65,9 @@ name = "relative-paths"
6565
working-directory = "relative-paths"
6666
command = "$<TARGET_FILE:cmkr>"
6767
arguments = ["build"]
68+
69+
[[test]]
70+
name = "objective-c"
71+
working-directory = "objective-c"
72+
command = "$<TARGET_FILE:cmkr>"
73+
arguments = ["build"]

tests/objective-c/cmake.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Add Objective-C sources on Apple platforms:
2+
3+
[project]
4+
name = "objective-c"
5+
description = "Objective-C"
6+
apple.languages = ["OBJC"]
7+
8+
[target.hello]
9+
type = "executable"
10+
sources = ["src/main.cpp"]
11+
apple.sources = ["src/apple.m"]

tests/objective-c/src/apple.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
void platform_specific() {
4+
// Print a message to stdout
5+
printf("Hello from Objective-C!\n");
6+
}

tests/objective-c/src/main.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
3+
#ifdef __APPLE__
4+
extern "C" void platform_specific();
5+
#else
6+
extern "C" void platform_specific() {
7+
puts("This is not an Apple platform.");
8+
}
9+
#endif
10+
11+
int main() {
12+
platform_specific();
13+
return 0;
14+
}

0 commit comments

Comments
 (0)