forked from OSchip/llvm-project
[cmake] Use absolute paths for modules search
For out of tree builds, the user generally needs to specify LLVM_DIR and MLIR_DIR on the command line so that the correct LLVM and MLIR installations are picked up. If the provided paths are absolute, everything works fine, however for buildbots it is customary to work with relative paths, and that makes it difficult for CMake to find the right modules to include. This patch changes CMakeLists.txt to convert LLVM_DIR and MLIR_DIR to absolute paths before adding them to CMAKE_MODULE_PATH. The inputs are assumed to be relative to the source directory (llvm-project/flang). Differential Revision: https://reviews.llvm.org/D87083
This commit is contained in:
parent
edf244217a
commit
d4b88ac165
|
@ -56,7 +56,10 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|||
|
||||
# We need a pre-built/installed version of LLVM.
|
||||
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
|
||||
list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
|
||||
# If the user specifies a relative path to LLVM_DIR, the calls to include
|
||||
# LLVM modules fail. Append the absolute path to LLVM_DIR instead.
|
||||
get_filename_component(LLVM_DIR_ABSOLUTE ${LLVM_DIR} REALPATH)
|
||||
list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR_ABSOLUTE})
|
||||
|
||||
# If LLVM links to zlib we need the imported targets so we can too.
|
||||
if(LLVM_ENABLE_ZLIB)
|
||||
|
@ -78,7 +81,10 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|||
find_package(MLIR REQUIRED CONFIG)
|
||||
# Use SYSTEM for the same reasons as for LLVM includes
|
||||
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
|
||||
list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR})
|
||||
# If the user specifies a relative path to MLIR_DIR, the calls to include
|
||||
# MLIR modules fail. Append the absolute path to MLIR_DIR instead.
|
||||
get_filename_component(MLIR_DIR_ABSOLUTE ${MLIR_DIR} REALPATH)
|
||||
list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR_ABSOLUTE})
|
||||
include(AddMLIR)
|
||||
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
|
||||
NO_DEFAULT_PATH)
|
||||
|
|
Loading…
Reference in New Issue