aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-03-13 14:30:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-03-13 14:30:56 -0700
commit4e9894cfc4c8e2e1d3e01aa2e3400b295b0ee2df (patch)
treeefc59febac4df5fb139b180ac4e8347b00f8fbe7 /CMakeLists.txt
parentcc650abf09d98ff241cc28b50b2519a9c4919dd0 (diff)
downloadzig-4e9894cfc4c8e2e1d3e01aa2e3400b295b0ee2df.tar.gz
zig-4e9894cfc4c8e2e1d3e01aa2e3400b295b0ee2df.zip
cmake build: allow overriding whether to use llvm-config
Previously, there was an option ZIG_PREFER_LLVM_CONFIG which would override the default of not using llvm-config when cross compiling. That option is now removed in favor of the more powerful ZIG_USE_LLVM_CONFIG which defaults to OFF for cross compiling and ON for native compilation. The option overrides the default. This will be used in zig-bootstrap to improve support for native builds.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt7
1 files changed, 6 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c0218e305..55198f3581 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,10 +87,15 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for")
set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")
-set(ZIG_PREFER_LLVM_CONFIG off CACHE BOOL "(when cross compiling) use llvm-config to find target llvm dependencies if needed")
set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1")
+if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
+ set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")
+else()
+ set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
+endif()
+
find_package(llvm)
find_package(clang)
find_package(lld)