]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | # Licensed to the Apache Software Foundation (ASF) under one |
2 | # or more contributor license agreements. See the NOTICE file | |
3 | # distributed with this work for additional information | |
4 | # regarding copyright ownership. The ASF licenses this file | |
5 | # to you under the Apache License, Version 2.0 (the | |
6 | # "License"); you may not use this file except in compliance | |
7 | # with the License. You may obtain a copy of the License at | |
8 | # | |
9 | # http://www.apache.org/licenses/LICENSE-2.0 | |
10 | # | |
11 | # Unless required by applicable law or agreed to in writing, | |
12 | # software distributed under the License is distributed on an | |
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | # KIND, either express or implied. See the License for the | |
15 | # specific language governing permissions and limitations | |
16 | # under the License. | |
17 | # | |
18 | # Usage of this module as follows: | |
19 | # | |
20 | # find_package(LLVMAlt) | |
21 | ||
22 | set(LLVM_HINTS ${LLVM_ROOT} ${LLVM_DIR} /usr/lib /usr/share) | |
23 | if(LLVM_BREW_PREFIX) | |
24 | list(APPEND LLVM_HINTS ${LLVM_BREW_PREFIX}) | |
25 | endif() | |
26 | foreach(ARROW_LLVM_VERSION ${ARROW_LLVM_VERSIONS}) | |
27 | find_package(LLVM | |
28 | ${ARROW_LLVM_VERSION} | |
29 | CONFIG | |
30 | HINTS | |
31 | ${LLVM_HINTS}) | |
32 | if(LLVM_FOUND) | |
33 | break() | |
34 | endif() | |
35 | endforeach() | |
36 | ||
37 | if(LLVM_FOUND) | |
38 | # Find the libraries that correspond to the LLVM components | |
39 | llvm_map_components_to_libnames(LLVM_LIBS | |
40 | core | |
41 | mcjit | |
42 | native | |
43 | ipo | |
44 | bitreader | |
45 | target | |
46 | linker | |
47 | analysis | |
48 | debuginfodwarf) | |
49 | ||
50 | find_program(LLVM_LINK_EXECUTABLE llvm-link HINTS ${LLVM_TOOLS_BINARY_DIR}) | |
51 | ||
52 | find_program(CLANG_EXECUTABLE | |
53 | NAMES clang-${LLVM_PACKAGE_VERSION} | |
54 | clang-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} | |
55 | clang-${LLVM_VERSION_MAJOR} clang | |
56 | HINTS ${LLVM_TOOLS_BINARY_DIR}) | |
57 | ||
58 | add_library(LLVM::LLVM_INTERFACE INTERFACE IMPORTED) | |
59 | ||
60 | set_target_properties(LLVM::LLVM_INTERFACE | |
61 | PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LLVM_INCLUDE_DIRS}" | |
62 | INTERFACE_COMPILE_FLAGS "${LLVM_DEFINITIONS}" | |
63 | INTERFACE_LINK_LIBRARIES "${LLVM_LIBS}") | |
64 | endif() | |
65 | ||
66 | mark_as_advanced(CLANG_EXECUTABLE LLVM_LINK_EXECUTABLE) | |
67 | ||
68 | find_package_handle_standard_args( | |
69 | LLVMAlt | |
70 | REQUIRED_VARS # The first variable is used for display. | |
71 | LLVM_PACKAGE_VERSION CLANG_EXECUTABLE LLVM_FOUND LLVM_LINK_EXECUTABLE) | |
72 | if(LLVMAlt_FOUND) | |
73 | message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") | |
74 | message(STATUS "Found llvm-link ${LLVM_LINK_EXECUTABLE}") | |
75 | message(STATUS "Found clang ${CLANG_EXECUTABLE}") | |
76 | endif() |