Skip to content

Commit 433dbb0

Browse files
committed
Add test for conditional Objective-C support
Closes #183
1 parent 4772a2b commit 433dbb0

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

docs/examples/objective-c.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
languages = ["C"]
19+
apple.languages = ["OBJC"]
20+
21+
[target.hello]
22+
type = "executable"
23+
sources = ["src/main.c"]
24+
apple.sources = ["src/apple.m"]
25+
apple.link-libraries = ["$<LINK_LIBRARY:FRAMEWORK,Foundation>"]
26+
```
27+
28+
29+
30+
<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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Add Objective-C sources on Apple platforms:
2+
3+
[project]
4+
name = "objective-c"
5+
description = "Objective-C"
6+
languages = ["C"]
7+
apple.languages = ["OBJC"]
8+
9+
[target.hello]
10+
type = "executable"
11+
sources = ["src/main.c"]
12+
apple.sources = ["src/apple.m"]
13+
apple.link-libraries = ["$<LINK_LIBRARY:FRAMEWORK,Foundation>"]

tests/objective-c/src/apple.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <Foundation/Foundation.h>
2+
3+
void platform_specific() {
4+
NSFileHandle *stdout = [NSFileHandle fileHandleWithStandardOutput];
5+
NSString *message = @"Hello from Objective-C!\n";
6+
[stdout writeData:[message dataUsingEncoding:NSUTF8StringEncoding] error:nil];
7+
}

tests/objective-c/src/main.c

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+
void platform_specific();
5+
#else
6+
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)