diff options
| author | Jonathan Marler <johnnymarler@gmail.com> | 2017-09-10 14:05:18 -0600 |
|---|---|---|
| committer | Jonathan Marler <jonathan.j.marler@hp.com> | 2017-09-11 09:26:26 -0600 |
| commit | 7c81cd30de876f8bc56a4c689372e4d388b8608c (patch) | |
| tree | 792c0783c39807575e40abd2d467e64e17d5d889 /cmake | |
| parent | 373785ae8d49d0ae3785020f05573763268ee9e1 (diff) | |
| download | zig-7c81cd30de876f8bc56a4c689372e4d388b8608c.tar.gz zig-7c81cd30de876f8bc56a4c689372e4d388b8608c.zip | |
Add support for MSVC
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/Findclang.cmake | 8 | ||||
| -rw-r--r-- | cmake/Findllvm.cmake | 45 |
2 files changed, 42 insertions, 11 deletions
diff --git a/cmake/Findclang.cmake b/cmake/Findclang.cmake index 04d3fb0201..486999b530 100644 --- a/cmake/Findclang.cmake +++ b/cmake/Findclang.cmake @@ -8,14 +8,20 @@ find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h PATHS + ${LLVM_INSTALL_PREFIX}/include /usr/lib/llvm/5/include /usr/lib/llvm-5.0/include /mingw64/include) - macro(FIND_AND_ADD_CLANG_LIB _libname_) +if(NOT CLANG_INCLUDE_DIRS) + message(FATAL_ERROR "Failed to find CLANG header files") +endif() + +macro(FIND_AND_ADD_CLANG_LIB _libname_) string(TOUPPER ${_libname_} _prettylibname_) find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_} PATHS + ${LLVM_INSTALL_PREFIX}/lib /usr/lib/llvm/5/lib /usr/lib/llvm-5.0/lib /mingw64/lib diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index 97e0a9a672..480bd17ce8 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -2,28 +2,53 @@ # This file is MIT licensed. # See http://opensource.org/licenses/MIT -# LLVM_FOUND # LLVM_INCLUDE_DIR # LLVM_LIBRARIES # LLVM_LIBDIRS -find_program(LLVM_CONFIG_EXE - NAMES llvm-config-5.0 llvm-config - PATHS - "/mingw64/bin" - "/c/msys64/mingw64/bin" - "c:/msys64/mingw64/bin" - "C:/Libraries/llvm-5.0.0/bin") +if(LLVM_INSTALL_PREFIX) + find_program(LLVM_CONFIG_EXE + NAMES llvm-config-5.0 llvm-config + PATHS ${LLVM_INSTALL_PREFIX}/bin + NO_DEFAULT_PATH) + if(NOT LLVM_CONFIG_EXE) + message(FATAL_ERROR "Invalid LLVM_INSTALL_PREFIX \"${LLVM_INSTALL_PREFIX}\", could not find llvm-config") + endif() +else() + find_program(LLVM_CONFIG_EXE + NAMES llvm-config-5.0 llvm-config + PATHS + "/mingw64/bin" + "/c/msys64/mingw64/bin" + "c:/msys64/mingw64/bin" + "C:/Libraries/llvm-5.0.0/bin") + if(NOT LLVM_CONFIG_EXE) + message(FATAL_ERROR "Could not find llvm-config, use -DLLVM_INSTALL_PREFIX to specify the install path") + endif() + execute_process( + COMMAND ${LLVM_CONFIG_EXE} --prefix + OUTPUT_VARIABLE LLVM_INSTALL_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if(${LLVM_INSTALL_PREFIX} MATCHES "^.* ") + # NOTE: this is a limitation due to llvm-config. If the path contains spaces then there's + # no way to tell from the output of llvm-config whether a space is seperating a filename, or + # just a space in the path name. + message(FATAL_ERROR "The LLVM install path \"${LLVM_INSTALL_PREFIX}\" cannot contain spaces") +endif() execute_process( COMMAND ${LLVM_CONFIG_EXE} --libs - OUTPUT_VARIABLE LLVM_LIBRARIES + OUTPUT_VARIABLE LLVM_LIBRARIES_STRING OUTPUT_STRIP_TRAILING_WHITESPACE) +string(REPLACE " " ";" LLVM_LIBRARIES ${LLVM_LIBRARIES_STRING}) execute_process( COMMAND ${LLVM_CONFIG_EXE} --system-libs - OUTPUT_VARIABLE LLVM_SYSTEM_LIBS + OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_STRING OUTPUT_STRIP_TRAILING_WHITESPACE) +string(REPLACE " " ";" LLVM_SYSTEM_LIBS ${LLVM_SYSTEM_LIBS_STRING}) execute_process( COMMAND ${LLVM_CONFIG_EXE} --libdir |
