Skip to content

Commit 82bd148

Browse files
authored
[mlir][cmake] Do not export MLIR_MAIN_SRC_DIR and MLIR_INCLUDE_DIR (#125842)
MLIR_MAIN_SRC_DIR and MLIR_INCLUDE_DIR point to the source directory, which is not installed. As such, the installed MLIRConfig.cmake also should not reference it. The comment indicates that these are needed for mlir_tablegen(), but I don't see any related uses. The motivation for this is the use in flang, where we end up inheriting a meaningless MLIR_MAIN_SRC_DIR from a previous MLIR build, whose source directory doesn't exist anymore, and that cannot be overridden with the correct path, because it's not a cached variable. Instead do what all the other projects do for LLVM_MAIN_SRC_DIR and initialize MLIR_MAIN_SRC_DIR to CMAKE_CURRENT_SOURCE_DIR/../mlir. For MLIR_INCLUDE_DIR there already is an exported MLIR_INCLUDE_DIRS, which can be used instead.
1 parent 7391327 commit 82bd148

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

flang/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
7979
message(FATAL_ERROR "flang isn't supported on 32 bit CPUs")
8080
endif()
8181

82+
set(MLIR_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../mlir" CACHE PATH "Path to MLIR source tree")
83+
8284
if (FLANG_STANDALONE_BUILD)
8385
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
8486
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -240,10 +242,9 @@ else()
240242
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
241243
endif()
242244

243-
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir ) # --src-root
244-
set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) # --includedir
245+
set(MLIR_INCLUDE_DIRS ${MLIR_MAIN_SRC_DIR}/include ) # --includedir
245246
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
246-
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
247+
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
247248
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
248249
endif()
249250

flang/include/flang/Optimizer/Dialect/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ set_target_properties(flang-doc PROPERTIES FOLDER "Flang/Docs")
3737
set(dialect_doc_filename "FIRLangRef")
3838

3939
set(LLVM_TARGET_DEFINITIONS FIROps.td)
40-
tablegen(MLIR ${dialect_doc_filename}.md -gen-op-doc "-I${MLIR_INCLUDE_DIR}")
40+
tablegen(MLIR ${dialect_doc_filename}.md -gen-op-doc)
4141
set(GEN_DOC_FILE ${FLANG_BINARY_DIR}/docs/Dialect/${dialect_doc_filename}.md)
4242
add_custom_command(
4343
OUTPUT ${GEN_DOC_FILE}

mlir/cmake/modules/MLIRConfig.cmake.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
1616
set(MLIR_ENABLE_BINDINGS_PYTHON "@MLIR_ENABLE_BINDINGS_PYTHON@")
1717
set(MLIR_ENABLE_EXECUTION_ENGINE "@MLIR_ENABLE_EXECUTION_ENGINE@")
1818

19-
# For mlir_tablegen()
20-
set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")
21-
set(MLIR_MAIN_SRC_DIR "@MLIR_MAIN_SRC_DIR@")
22-
2319
set_property(GLOBAL PROPERTY MLIR_ALL_LIBS "@MLIR_ALL_LIBS@")
2420
set_property(GLOBAL PROPERTY MLIR_DIALECT_LIBS "@MLIR_DIALECT_LIBS@")
2521
set_property(GLOBAL PROPERTY MLIR_CONVERSION_LIBS "@MLIR_CONVERSION_LIBS@")

0 commit comments

Comments
 (0)