[cmake] move FindLLVM to its own file
[blender.git] / CMakeLists.txt
index ea1ca3d37b2d35b1a123837425ee0a795afe8b61..ae2c67b59bfbff1ff97bda1c49771ca23a78c6b9 100644 (file)
@@ -1059,70 +1059,13 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
-       # XXX Maybe most of this section should go into an llvm module?
        if(WITH_LLVM)
+        find_package_wrapper(LLVM)
 
-               if(LLVM_ROOT_DIR)
-                       if(NOT DEFINED LLVM_VERSION)
-                               find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_ROOT_DIR}/bin NO_CMAKE_PATH)
-                       endif()
-                       if(NOT LLVM_CONFIG)
-                               find_program(LLVM_CONFIG llvm-config HINTS ${LLVM_ROOT_DIR}/bin NO_CMAKE_PATH)
-                       endif()
-               else()
-                       if(NOT DEFINED LLVM_VERSION)
-                               find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION})
-                       endif()
-                       if(NOT LLVM_CONFIG)
-                               find_program(LLVM_CONFIG llvm-config)
-                       endif()
-               endif()
-
-               if(NOT DEFINED LLVM_VERSION)
-                       execute_process(COMMAND ${LLVM_CONFIG} --version
-                                                       OUTPUT_VARIABLE LLVM_VERSION
-                                                       OUTPUT_STRIP_TRAILING_WHITESPACE)
-                       set(LLVM_VERSION ${LLVM_VERSION} CACHE STRING "Version of LLVM to use")
+        if(NOT LLVM_FOUND)
+                       set(WITH_LLVM OFF)
+                       message(STATUS "LLVM not found")
                endif()
-               if(NOT DEFINED LLVM_ROOT_DIR)
-                       execute_process(COMMAND ${LLVM_CONFIG} --prefix
-                                                       OUTPUT_VARIABLE LLVM_ROOT_DIR
-                                                       OUTPUT_STRIP_TRAILING_WHITESPACE)
-                       set(LLVM_ROOT_DIR ${LLVM_ROOT_DIR} CACHE PATH "Path to the LLVM installation")
-               endif()
-               if(NOT DEFINED LLVM_LIBPATH)
-                       execute_process(COMMAND ${LLVM_CONFIG} --libdir
-                                                       OUTPUT_VARIABLE LLVM_LIBPATH
-                                                       OUTPUT_STRIP_TRAILING_WHITESPACE)
-                       set(LLVM_LIBPATH ${LLVM_LIBPATH} CACHE PATH "Path to the LLVM library path")
-                       mark_as_advanced(LLVM_LIBPATH)
-               endif()
-
-               if(LLVM_STATIC)
-                       find_library(LLVM_LIBRARY
-                                    NAMES LLVMAnalysis # first of a whole bunch of libs to get
-                                    PATHS ${LLVM_LIBPATH})
-               else()
-                       find_library(LLVM_LIBRARY
-                                    NAMES LLVM-${LLVM_VERSION}
-                                    PATHS ${LLVM_LIBPATH})
-               endif()
-
-
-               if(LLVM_LIBRARY AND LLVM_ROOT_DIR AND LLVM_LIBPATH)
-                       if(LLVM_STATIC)
-                               # if static LLVM libraries were requested, use llvm-config to generate
-                               # the list of what libraries we need, and substitute that in the right
-                               # way for LLVM_LIBRARY.
-                               execute_process(COMMAND ${LLVM_CONFIG} --libfiles
-                                               OUTPUT_VARIABLE LLVM_LIBRARY
-                                               OUTPUT_STRIP_TRAILING_WHITESPACE)
-                               string(REPLACE " " ";" LLVM_LIBRARY "${LLVM_LIBRARY}")
-                       endif()
-               else()
-                       message(FATAL_ERROR "LLVM not found.")
-               endif()
-
        endif()
 
        if(WITH_LLVM OR WITH_SDL_DYNLOAD)