diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-07 12:18:01 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-07 12:18:01 -0500 |
| commit | 7843c96df87007561c107d11afa2fa74b46667fd (patch) | |
| tree | 41a2e30392e332361d67ce77a457deccf5e49e1c /cmake | |
| parent | 2b2bf53a49616192e2b2bdf40b88400964ff1500 (diff) | |
| download | zig-7843c96df87007561c107d11afa2fa74b46667fd.tar.gz zig-7843c96df87007561c107d11afa2fa74b46667fd.zip | |
build: make sure LLVM is exactly correct
* check the version to be the correct major version
* ensure that it has all the default targets enabled
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/Findllvm.cmake | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index 70d50f9843..2f0afa09b7 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -15,15 +15,51 @@ find_program(LLVM_CONFIG_EXE "c:/msys64/mingw64/bin" "C:/Libraries/llvm-7.0.0/bin") +if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND") + message(FATAL_ERROR "unable to find llvm-config") +endif() + execute_process( COMMAND ${LLVM_CONFIG_EXE} --version OUTPUT_VARIABLE LLVM_CONFIG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -if(LLVM_CONFIG_VERSION VERSION_LESS 7) - message(FATAL_ERROR "expected LLVM version >=7 but found ${LLVM_CONFIG_VERSION}") +if("${LLVM_CONFIG_VERSION}" VERSION_LESS 7) + message(FATAL_ERROR "expected LLVM 7.x but found ${LLVM_CONFIG_VERSION}") +endif() +if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 8) + message(FATAL_ERROR "expected LLVM 7.x but found ${LLVM_CONFIG_VERSION}") +endif() +if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 8) + message(FATAL_ERROR "expected LLVM 7.x but found ${LLVM_CONFIG_VERSION}") endif() +execute_process( + COMMAND ${LLVM_CONFIG_EXE} --targets-built + OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES + OUTPUT_STRIP_TRAILING_WHITESPACE) +string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}") +function(NEED_TARGET TARGET_NAME) + list (FIND LLVM_TARGETS_BUILT "${TARGET_NAME}" _index) + if (${_index} EQUAL -1) + message(FATAL_ERROR "LLVM is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.") + endif() +endfunction(NEED_TARGET) +NEED_TARGET("AArch64") +NEED_TARGET("AMDGPU") +NEED_TARGET("ARM") +NEED_TARGET("BPF") +NEED_TARGET("Hexagon") +NEED_TARGET("Lanai") +NEED_TARGET("Mips") +NEED_TARGET("MSP430") +NEED_TARGET("NVPTX") +NEED_TARGET("PowerPC") +NEED_TARGET("Sparc") +NEED_TARGET("SystemZ") +NEED_TARGET("X86") +NEED_TARGET("XCore") + if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug") OR ZIG_STATIC) execute_process( COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static |
