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_
120120set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
121121set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
122122set(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
124125if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
125126 set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")
......@@ -127,6 +128,11 @@ else()
127128 set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
128129endif()
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
130136find_package(llvm 15)
131137find_package(clang 15)
132138find_package(lld 15)
ci/aarch64-windows.ps1+1-2
......@@ -46,8 +46,7 @@ Set-Location -Path 'build-release'
4646 -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
4747 -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
4848 -DCMAKE_AR="$ZIG" `
49 -DCMAKE_C_ARCHIVE_CREATE="<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>" `
50 -DCMAKE_CXX_ARCHIVE_CREATE="<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>" `
49 -DZIG_AR_WORKAROUND=ON `
5150 -DZIG_TARGET_TRIPLE="$TARGET" `
5251 -DZIG_TARGET_MCPU="$MCPU" `
5352 -DZIG_STATIC=ON