forked from ldc-developers/ldc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MLIR: #1 CMake Modifications to allow MLIR Support
MLIR: #2 CMake - Adding FindMLIR.cmake MLIR: #3 CMake - Updating FindMLIR MLIR: #4 CMake - Updating Path MLIR: #5 CMake - Adding MLIRLibs MLIR: #6 CMake - Supporting Dialect on FindMLIR MLIR: #7 CMake - Adding Message of Ops.ts MLIR: ldc-developers#8 CMake - Removing duplicated messages MLIR: ldc-developers#9 CMake: Updating paths and setting libs MLIR: ldc-developers#10 CMake - Removing duplicated MLIR Headers Make MLIR optional, use MLIR_LIBRARIES
- Loading branch information
1 parent
3f5e526
commit ec02b7b
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# - Try to find MLIR project at LLVM | ||
# | ||
# The following are set after configuration is done: | ||
# MLIR_FOUND | ||
# MLIR_ROOT_DIRS | ||
# MLIR_INCLUDE_DIRS | ||
# MLIR_BUILD_INCLUDE_DIR | ||
project(ldc) | ||
|
||
find_path(MLIR_ROOT_DIR NAMES "LICENSE.TXT" HINTS ${LLVM_ROOT_DIR}/../mlir) | ||
|
||
#Used to get the main header files | ||
find_path(MLIR_INCLUDE_DIR NAMES "Parser.h" HINTS ${MLIR_ROOT_DIR}/include/mlir) | ||
|
||
#Lib directories | ||
find_path(MLIR_LIB_DIR NAMES "CMakeLists.txt" HINTS ${MLIR_ROOT_DIR}/lib/IR) | ||
|
||
#Used to get StandardOps.h.inc | ||
find_path(MLIR_BUILD_INCLUDE_DIR NAMES "cmake_install.cmake" | ||
HINTS ${LLVM_ROOT_DIR}/tools/mlir/include/mlir) | ||
|
||
message(STATUS "MLIR Dir: ${MLIR_ROOT_DIR}") | ||
message(STATUS "MLIR Include Dir: ${MLIR_INCLUDE_DIR}/..") | ||
message(STATUS "MLIR Lib Dir: ${MLIR_LIB_DIR}/..") | ||
message(STATUS "MLIR Build Include Dir: ${MLIR_BUILD_INCLUDE_DIR}/..") | ||
|
||
set(MLIR_ROOT_DIRS ${MLIR_ROOT_DIR}) | ||
set(MLIR_INCLUDE_DIRS ${MLIR_INCLUDE_DIR}/..) | ||
set(MLIR_BUILD_INCLUDE_DIRS ${MLIR_BUILD_INCLUDE_DIR}/..) | ||
set(MLIR_LIB_DIRS ${MLIR_LIB_DIR}/..) | ||
|
||
if(EXISTS ${MLIR_ROOT_DIR}) | ||
#Resources to automatically generate Ops.h.inc and Ops.cpp.inc, assuming that | ||
#mlir-tblgen is already built and is on the usual directory at llvm dir | ||
set(MLIR_MAIN_SRC_DIR ${MLIR_INCLUDE_DIR}/.. ) | ||
set(MLIR_TABLEGEN_EXE ${LLVM_ROOT_DIR}/bin/mlir-tblgen) | ||
set(MLIR_INCLUDE_DIR ${MLIR_BUILD_INCLUDE_DIR}/..) | ||
|
||
function(mlir_tablegen) | ||
cmake_parse_arguments( | ||
ARG | ||
"NAME" | ||
"TARGET;OUTS;FLAG;SRCS" | ||
${ARGN} | ||
) | ||
|
||
MESSAGE(STATUS "Setting target for Ops_" ${ARG_TARGET}) | ||
|
||
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SRCS} | ||
PARENT_SCOPE) | ||
#mlir-tblgen ops.td --gen-op-* -I*-o=ops.*.inc | ||
add_custom_command( | ||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTS} | ||
COMMAND ${MLIR_TABLEGEN_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SRCS} -I${MLIR_MAIN_SRC_DIR} -I${MLIR_INCLUDE_DIR} -o=${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTS} | ||
ARGS ${ARG_FLAG} | ||
) | ||
add_custom_target(Ops_${ARG_TARGET} ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTS}) | ||
endfunction() | ||
|
||
# Handle the QUIETLY and REQUIRED arguments and set the MLIR_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(MLIR DEFAULT_MSG MLIR_ROOT_DIRS MLIR_INCLUDE_DIRS | ||
MLIR_BUILD_INCLUDE_DIRS MLIR_LIB_DIRS) | ||
|
||
mark_as_advanced(MLIR_ROOT_DIRS MLIR_INCLUDE_DIRS MLIR_BUILD_INCLUDE_DIRS MLIR_LIB_DIRS) | ||
endif() |