authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-09 16:19:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-10 16:28:49-07:00
logcacb962ba725c7127fa4b92d98fa2bde25e4c53c
tree293fb70677177b2e4a77a640de039953f426c42f
parentc9231f05470a1abc600010c72a535de883731da6

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.

2 files changed, 7 insertions(+), 2 deletions(-)

CMakeLists.txt+6
...@@ -120,6 +120,7 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_...@@ -120,6 +120,7 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_
120set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")120set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
121set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")121set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
122set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")122set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
123set(ZIG_AR_WORKAROUND off CACHE BOOL "append 'ar' subcommand to CMAKE_AR")
123124
124if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")125if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
125 set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")126 set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")
...@@ -127,6 +128,11 @@ else()...@@ -127,6 +128,11 @@ else()
127 set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")128 set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
128endif()129endif()
129130
131if(ZIG_AR_WORKAROUND)
132 string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_C_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
133 string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
134endif()
135
130find_package(llvm 15)136find_package(llvm 15)
131find_package(clang 15)137find_package(clang 15)
132find_package(lld 15)138find_package(lld 15)
ci/aarch64-windows.ps1+1-2
...@@ -46,8 +46,7 @@ Set-Location -Path 'build-release'...@@ -46,8 +46,7 @@ Set-Location -Path 'build-release'
46 -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `46 -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
47 -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `47 -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
48 -DCMAKE_AR="$ZIG" `48 -DCMAKE_AR="$ZIG" `
49 -DCMAKE_C_ARCHIVE_CREATE="<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>" `49 -DZIG_AR_WORKAROUND=ON `
50 -DCMAKE_CXX_ARCHIVE_CREATE="<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>" `
51 -DZIG_TARGET_TRIPLE="$TARGET" `50 -DZIG_TARGET_TRIPLE="$TARGET" `
52 -DZIG_TARGET_MCPU="$MCPU" `51 -DZIG_TARGET_MCPU="$MCPU" `
53 -DZIG_STATIC=ON52 -DZIG_STATIC=ON