aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-09 16:19:25 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-12-10 16:28:49 -0700
commitcacb962ba725c7127fa4b92d98fa2bde25e4c53c (patch)
tree293fb70677177b2e4a77a640de039953f426c42f
parentc9231f05470a1abc600010c72a535de883731da6 (diff)
downloadzig-cacb962ba725c7127fa4b92d98fa2bde25e4c53c.tar.gz
zig-cacb962ba725c7127fa4b92d98fa2bde25e4c53c.zip
CMake: add workaround for CMAKE_AR not supporting spaces
This allows using `zig ar` for `CMAKE_AR`. Unfortunately, it requires a patch to CMakeLists.txt and cannot be done merely with flags to the cmake line.
-rw-r--r--CMakeLists.txt6
-rw-r--r--ci/aarch64-windows.ps13
2 files changed, 7 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f3f73690a..dcade34e2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -120,6 +120,7 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_
set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
+set(ZIG_AR_WORKAROUND off CACHE BOOL "append 'ar' subcommand to CMAKE_AR")
if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")
@@ -127,6 +128,11 @@ else()
set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
endif()
+if(ZIG_AR_WORKAROUND)
+ string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_C_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
+ string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
+endif()
+
find_package(llvm 15)
find_package(clang 15)
find_package(lld 15)
diff --git a/ci/aarch64-windows.ps1 b/ci/aarch64-windows.ps1
index 5d7da61985..171f196990 100644
--- a/ci/aarch64-windows.ps1
+++ b/ci/aarch64-windows.ps1
@@ -46,8 +46,7 @@ Set-Location -Path 'build-release'
-DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
-DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
-DCMAKE_AR="$ZIG" `
- -DCMAKE_C_ARCHIVE_CREATE="<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>" `
- -DCMAKE_CXX_ARCHIVE_CREATE="<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>" `
+ -DZIG_AR_WORKAROUND=ON `
-DZIG_TARGET_TRIPLE="$TARGET" `
-DZIG_TARGET_MCPU="$MCPU" `
-DZIG_STATIC=ON