authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-30 13:20:13-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-30 13:20:13-04:00
logf586acabdcc4adaeda7bc278463c20e4033e8cc9
tree5b94df731d3515a56da9aaf233d59cf6398263eb
parentedca1739975f69a695d1ee12ba88ebca1778fefb

add ZIG_STATIC cmake option

it's not compatible with glibc but it works with musl

2 files changed, 4 insertions(+), 1 deletions(-)

CMakeLists.txt+3
......@@ -35,6 +35,7 @@ set(ZIG_LIBC_STATIC_LIB_DIR "" CACHE STRING "Default native target libc director
3535set(ZIG_LIBC_INCLUDE_DIR "/usr/include" CACHE STRING "Default native target libc include directory")
3636set(ZIG_DYNAMIC_LINKER "" CACHE STRING "Override dynamic linker for native target")
3737set(ZIG_EACH_LIB_RPATH off CACHE BOOL "Add each dynamic library to rpath for native target")
38set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
3839
3940string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}")
4041string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_STATIC_LIB_DIR_ESCAPED "${ZIG_LIBC_STATIC_LIB_DIR}")
......@@ -698,6 +699,8 @@ if(MINGW)
698699 set(EXE_LDFLAGS "-static -static-libgcc -static-libstdc++")
699700elseif(MSVC)
700701 set(EXE_LDFLAGS "/STACK:16777216")
702elseif(ZIG_STATIC)
703 set(EXE_LDFLAGS "-static")
701704else()
702705 set(EXE_LDFLAGS " ")
703706endif()
cmake/Findllvm.cmake+1-1
......@@ -15,7 +15,7 @@ find_program(LLVM_CONFIG_EXE
1515 "c:/msys64/mingw64/bin"
1616 "C:/Libraries/llvm-6.0.0/bin")
1717
18if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
18if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug") OR ZIG_STATIC)
1919 execute_process(
2020 COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static
2121 OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES