Skip to content

Commit 5931e7d

Browse files
committed
use cmake --build and the default generator instead of makefiles
1 parent 15fb9fa commit 5931e7d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For other versions, check the git tags of this repository.
2626
* C++ compiler capable of building LLVM, Clang, and LLD from source (GCC 5.1+
2727
or Clang)
2828
* cmake 3.19 or later
29-
* make
29+
* make, ninja, or any other build system supported by cmake
3030
* POSIX system (bash, mkdir, cd)
3131
* Python 3
3232

@@ -38,14 +38,16 @@ For other versions, check the git tags of this repository.
3838

3939
All parameters are required:
4040

41-
* `-j1`: Replace with your jobs parameter to make.
41+
* `-j1`: Replace with your jobs parameter to cmake.
4242
* `<arch>-<os>-<abi>`: Replace with one of the Supported Triples below, or use
4343
`native` for the `<arch>` value (e.g. `native-linux-gnu`) to use the native
4444
architecture.
4545
* `baseline`: Replace with a `-mcpu` parameter of Zig. `baseline` means
4646
it will target a generic CPU for the target. `native` means it will target
4747
the native CPU. See the Zig documentation for more details.
4848

49+
To use a non-default cmake generator, export the `CMAKE_GENERATOR` environment variable before calling `build`.
50+
4951
If it succeeds, the output will be in `out/zig-triple-mcpu/`.
5052

5153
### Supported Triples

build

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ case $TARGET_OS_CMAKE in
2121
native) TARGET_OS_CMAKE="";;
2222
esac
2323

24-
export CMAKE_GENERATOR="Unix Makefiles"
25-
2624
# First build the libraries for Zig to link against, as well as native `llvm-tblgen`.
2725
mkdir -p "$ROOTDIR/out/build-llvm-host"
2826
cd "$ROOTDIR/out/build-llvm-host"
@@ -43,7 +41,7 @@ cmake "$ROOTDIR/llvm" \
4341
-DCLANG_INCLUDE_DOCS=OFF \
4442
-DLLVM_INCLUDE_DOCS=OFF \
4543
-DCMAKE_BUILD_TYPE=Release
46-
make "$JOBS" install
44+
cmake --build . "$JOBS" --target install
4745

4846
# Now we build Zig, still with system C/C++ compiler, linking against LLVM,
4947
# Clang, LLD we just built from source.
@@ -54,7 +52,7 @@ cmake "$ROOTDIR/zig" \
5452
-DCMAKE_PREFIX_PATH="$ROOTDIR/out/host" \
5553
-DCMAKE_BUILD_TYPE=Release \
5654
-DZIG_VERSION="$ZIG_VERSION"
57-
make "$JOBS" install
55+
cmake --build . "$JOBS" --target install
5856

5957
# Now we have Zig as a cross compiler.
6058
ZIG="$ROOTDIR/out/host/bin/zig"
@@ -75,7 +73,7 @@ cmake "$ROOTDIR/zlib" \
7573
-DCMAKE_RC_COMPILER="$ROOTDIR/out/host/bin/llvm-rc" \
7674
-DCMAKE_AR="$ROOTDIR/out/host/bin/llvm-ar" \
7775
-DCMAKE_RANLIB="$ROOTDIR/out/host/bin/llvm-ranlib"
78-
make "$JOBS" install
76+
cmake --build . "$JOBS" --target install
7977

8078
# Same deal for zstd.
8179
# The build system for zstd is whack so I just put all the files here.
@@ -163,13 +161,13 @@ cmake "$ROOTDIR/llvm" \
163161
-DLIBCLANG_BUILD_STATIC=ON \
164162
-DLLVM_DEFAULT_TARGET_TRIPLE="$TARGET"
165163
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU/tools/lld"
166-
make "$JOBS" install
164+
cmake --build . "$JOBS" --target install
167165
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU/tools/clang/lib"
168-
make "$JOBS" install
166+
cmake --build . "$JOBS" --target install
169167
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU/lib"
170-
make "$JOBS" install
168+
cmake --build . "$JOBS" --target install
171169
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU"
172-
make "$JOBS" install-llvm-headers install-clang-headers install-LLVMSupport install-LLVMDemangle
170+
cmake --build . "$JOBS" --target install-llvm-headers install-clang-headers install-LLVMSupport install-LLVMDemangle
173171

174172
# Finally, we can cross compile Zig itself, with Zig.
175173
cd "$ROOTDIR/zig"

0 commit comments

Comments
 (0)