From 652b2fd76ba559b0c7e1304b8d879e48feb26fad Mon Sep 17 00:00:00 2001 From: Yannick Stade <100073938+ystade@users.noreply.github.com> Date: Thu, 22 May 2025 16:06:19 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9A=B8=20add=20dedicated=20MLIR=20set?= =?UTF-8?q?up=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- CMakeLists.txt | 1 + cmake/SetupMLIR.cmake | 44 +++++++++++++++++++++++++++++++++++++++++++ mlir/CMakeLists.txt | 37 ------------------------------------ 3 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 cmake/SetupMLIR.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b039e24e8b..94119e2396 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/SetupMLIR.cmake b/cmake/SetupMLIR.cmake new file mode 100644 index 0000000000..9f17a4688a --- /dev/null +++ b/cmake/SetupMLIR.cmake @@ -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}") + +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_BINARY_DIR}/mlir/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}) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 91e4de8d00..f74a4ad202 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -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) From 6d824fc636391187c418e1d1d965bb375b9f6127 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Thu, 22 May 2025 16:09:34 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20avoid=20duplicate=20definiti?= =?UTF-8?q?on=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- cmake/SetupMLIR.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/SetupMLIR.cmake b/cmake/SetupMLIR.cmake index 9f17a4688a..45a39682d7 100644 --- a/cmake/SetupMLIR.cmake +++ b/cmake/SetupMLIR.cmake @@ -22,10 +22,6 @@ message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") 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) @@ -39,6 +35,10 @@ 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})