Skip to content

Commit c95e1ae

Browse files
authored
save
1 parent cf7a4fa commit c95e1ae

14 files changed

+171
-0
lines changed

src/cosmocc-toolchain/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ cmake --build ./build/
3737
```
3838
<!-- cmdrun cmake --build ./build/ --clean-first -->
3939
```
40+
41+
<details>
42+
43+
```sh:
44+
./build/cosmocc-toolchain
45+
```
46+
47+
```
48+
<!-- cmdrun ./build/cosmocc-toolchain -->
49+
```
50+
51+
</details>

src/zig-toolchain/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
3+
project(zig-toolchain)
4+
5+
add_executable(zig-toolchain main.c)

src/zig-toolchain/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
11
# Zig toolchain
2+
3+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/jcbhmr/cmakebyexample.jcbhmr.com?quickstart=1&devcontainer_path=.devcontainer%2Fzig-toolchain%2Fdevcontainer.json)
4+
5+
```cmake:cmake/zig-x86_64-linux-musl.cmake
6+
{{#include cmake/cosmocc.cmake}}
7+
```
8+
9+
<details>
10+
11+
```c:main.c
12+
{{#include main.c}}
13+
```
14+
15+
```cmake:CMakeLists.txt
16+
{{#include CMakeLists.txt}}
17+
```
18+
19+
</details>
20+
21+
```sh:
22+
cmake --toolchain ./cmake/zig-x86_64-linux-musl.cmake -B ./build/
23+
```
24+
25+
```
26+
<!-- cmdrun cmake --fresh --toolchain ./cmake/zig-x86_64-linux-musl.cmake -B ./build/ -->
27+
```
28+
29+
```sh:
30+
cmake --build ./build/
31+
```
32+
33+
```
34+
<!-- cmdrun cmake --build ./build/ --clean-first -->
35+
```
36+
37+
<details>
38+
39+
```sh:
40+
./build/zig-toolchain
41+
```
42+
43+
```
44+
<!-- cmdrun ./build/zig-toolchain -->
45+
```
46+
47+
</details>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(CMAKE_SYSTEM_NAME Linux)
2+
set(CMAKE_SYSTEM_PROCESSOR aarch64)
3+
4+
set(CMAKE_ASM_COMPILER "zig" "cc")
5+
set(CMAKE_ASM_COMPILER_TARGET "aarch64-linux-musl")
6+
7+
set(CMAKE_C_COMPILER "zig" "cc")
8+
set(CMAKE_C_COMPILER_TARGET "aarch64-linux-musl")
9+
10+
set(CMAKE_CXX_COMPILER "zig" "c++")
11+
set(CMAKE_CXX_COMPILER_TARGET "aarch64-linux-musl")
12+
13+
find_program(CMAKE_AR "${CMAKE_CURRENT_LIST_DIR}/zig-ar" REQUIRED)
14+
15+
find_program(CMAKE_RANLIB "${CMAKE_CURRENT_LIST_DIR}/zig-ranlib" REQUIRED)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(CMAKE_SYSTEM_NAME Darwin)
2+
set(CMAKE_SYSTEM_PROCESSOR arm64)
3+
4+
set(CMAKE_ASM_COMPILER "zig" "cc")
5+
set(CMAKE_ASM_COMPILER_TARGET "aarch64-macos-none")
6+
7+
set(CMAKE_C_COMPILER "zig" "cc")
8+
set(CMAKE_C_COMPILER_TARGET "aarch64-macos-none")
9+
10+
set(CMAKE_CXX_COMPILER "zig" "c++")
11+
set(CMAKE_CXX_COMPILER_TARGET "aarch64-macos-none")
12+
13+
find_program(CMAKE_AR "${CMAKE_CURRENT_LIST_DIR}/zig-ar" REQUIRED)
14+
15+
find_program(CMAKE_RANLIB "${CMAKE_CURRENT_LIST_DIR}/zig-ranlib" REQUIRED)

src/zig-toolchain/cmake/zig-ar

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec zig ar "$@"

src/zig-toolchain/cmake/zig-ar.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@zig ar %*

src/zig-toolchain/cmake/zig-ranlib

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec zig ranlib "$@"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@zig ranlib %*
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(CMAKE_SYSTEM_NAME WASI)
2+
set(CMAKE_SYSTEM_PROCESSOR wasm32)
3+
4+
set(CMAKE_ASM_COMPILER "zig" "cc")
5+
set(CMAKE_ASM_COMPILER_TARGET "wasm32-wasi-musl")
6+
7+
set(CMAKE_C_COMPILER "zig" "cc")
8+
set(CMAKE_C_COMPILER_TARGET "wasm32-wasi-musl")
9+
10+
set(CMAKE_CXX_COMPILER "zig" "c++")
11+
set(CMAKE_CXX_COMPILER_TARGET "wasm32-wasi-musl")
12+
13+
find_program(CMAKE_AR "${CMAKE_CURRENT_LIST_DIR}/zig-ar" REQUIRED)
14+
15+
find_program(CMAKE_RANLIB "${CMAKE_CURRENT_LIST_DIR}/zig-ranlib" REQUIRED)

0 commit comments

Comments
 (0)