From 3a67c13b5db7efe28d4656d5da808f42ac026cc3 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 9 Jul 2019 19:03:57 +1000 Subject: cmake: allow user to select static vs dynamic LLVM --- CMakeLists.txt | 5 +++++ cmake/Findllvm.cmake | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21a6ce82e8..d8cf0c507d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,11 @@ endif() message("Configuring zig version ${ZIG_VERSION}") set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") +set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries") + +if(ZIG_STATIC) + set(ZIG_STATIC_LLVM "on") +endif() string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}") string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_STATIC_LIB_DIR_ESCAPED "${ZIG_LIBC_STATIC_LIB_DIR}") diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index e13c1e741c..3eb6bd9003 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -65,7 +65,7 @@ NEED_TARGET("WebAssembly") NEED_TARGET("X86") NEED_TARGET("XCore") -if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug") OR ZIG_STATIC) +if(ZIG_STATIC_LLVM) execute_process( COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES -- cgit v1.2.3