Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ endif()

option(BUILD_MQT_CORE_MLIR "Build the MLIR submodule of the MQT Core project" OFF)
if(BUILD_MQT_CORE_MLIR)
include(SetupMLIR)
add_subdirectory(mlir)
endif()

Expand Down
44 changes: 44 additions & 0 deletions cmake/SetupMLIR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
# Copyright (c) 2025 Munich Quantum Software Company GmbH
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

# set the include directory for the build tree
set(MQT_MLIR_INCLUDE_BUILD_DIR "${CMAKE_SOURCE_DIR}/mlir/include")
set(MQT_MLIR_MIN_VERSION 19.0)

# MLIR must be installed on the system
find_package(MLIR REQUIRED CONFIG)
if(MLIR_VERSION VERSION_LESS MQT_MLIR_MIN_VERSION)
message(FATAL_ERROR "MLIR version must be at least ${MQT_MLIR_MIN_VERSION}")
endif()
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

# Add the paths to the MLIR and LLVM CMake modules.
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")

# Include the TableGen, LLVM and MLIR CMake modules.
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)

include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${MQT_MLIR_INCLUDE_BUILD_DIR})
include_directories(${CMAKE_BINARY_DIR}/mlir/include)
link_directories(${LLVM_BUILD_LIBRARY_DIR})
add_definitions(${LLVM_DEFINITIONS})

string(REPLACE "." ";" MLIR_VERSION_COMPONENTS ${MLIR_VERSION})
list(GET MLIR_VERSION_COMPONENTS 0 MLIR_VERSION_MAJOR)
add_compile_definitions(MLIR_VERSION_MAJOR=${MLIR_VERSION_MAJOR})

# set the binary directory for the build tree such that, e.g., docs can be generated in the build
# tree
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
37 changes: 0 additions & 37 deletions mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,6 @@
#
# Licensed under the MIT License

# set the include directory for the build tree
set(MQT_MLIR_INCLUDE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(MQT_MLIR_MIN_VERSION 19.0)

# MLIR must be installed on the system
find_package(MLIR REQUIRED CONFIG)
if(MLIR_VERSION VERSION_LESS MQT_MLIR_MIN_VERSION)
message(FATAL_ERROR "MLIR version must be at least ${MQT_MLIR_MIN_VERSION}")
endif()
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

# Add the paths to the MLIR and LLVM CMake modules.
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")

string(REPLACE "." ";" MLIR_VERSION_COMPONENTS ${MLIR_VERSION})
list(GET MLIR_VERSION_COMPONENTS 0 MLIR_VERSION_MAJOR)
add_compile_definitions(MLIR_VERSION_MAJOR=${MLIR_VERSION_MAJOR})

# Include the TableGen, LLVM and MLIR CMake modules.
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)

include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${MQT_MLIR_INCLUDE_BUILD_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
link_directories(${LLVM_BUILD_LIBRARY_DIR})
add_definitions(${LLVM_DEFINITIONS})

# set the binary directory for the build tree such that, e.g., docs can be generated in the build
# tree
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})

# add a compile feature for C++17
set(CMAKE_CXX_STANDARD 17)

Expand Down
Loading