Skip to content

Commit 205aa26

Browse files
burgholzerdenialhaag
authored andcommitted
📦 allow building MLIR libraries as shared libraries
Signed-off-by: burgholzer <burgholzer@me.com>
1 parent ed97c45 commit 205aa26

8 files changed

Lines changed: 74 additions & 8 deletions

File tree

mlir/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ if(ENABLE_COVERAGE)
1515
add_link_options(--coverage)
1616
endif()
1717

18+
# Conditionally set SHARED keyword for shared library builds
19+
if(BUILD_MQT_CORE_SHARED_LIBS)
20+
set(MQT_CORE_MLIR_LIBRARY_TYPE SHARED)
21+
else()
22+
set(MQT_CORE_MLIR_LIBRARY_TYPE)
23+
endif()
24+
1825
# add main library code
1926
add_subdirectory(include)
2027
add_subdirectory(lib)

mlir/lib/Conversion/MQTOptToMQTRef/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@
88

99
file(GLOB CONVERSION_SOURCES *.cpp)
1010

11-
add_mlir_library(MQTOptToMQTRef ${CONVERSION_SOURCES} DEPENDS MQTOptToMQTRefIncGen)
11+
add_mlir_library(
12+
MQTOptToMQTRef
13+
${CONVERSION_SOURCES}
14+
DEPENDS
15+
MQTOptToMQTRefIncGen
16+
LINK_LIBS
17+
MLIRMQTOpt
18+
MLIRMQTRef
19+
MLIRMemRefDialect
20+
MLIRTransforms
21+
MLIRFuncDialect
22+
MLIRFuncTransforms)

mlir/lib/Conversion/MQTRefToMQTOpt/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@
88

99
file(GLOB CONVERSION_SOURCES *.cpp)
1010

11-
add_mlir_library(MQTRefToMQTOpt ${CONVERSION_SOURCES} DEPENDS MQTRefToMQTOptIncGen)
11+
add_mlir_library(
12+
MQTRefToMQTOpt
13+
${CONVERSION_SOURCES}
14+
DEPENDS
15+
MQTRefToMQTOptIncGen
16+
LINK_LIBS
17+
MLIRMQTOpt
18+
MLIRMQTRef
19+
MLIRMemRefDialect
20+
MLIRTransforms
21+
MLIRFuncDialect
22+
MLIRFuncTransforms)

mlir/lib/Conversion/MQTRefToQIR/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@
88

99
file(GLOB CONVERSION_SOURCES *.cpp)
1010

11-
add_mlir_library(MQTRefToQIR ${CONVERSION_SOURCES} DEPENDS MQTRefToQIRIncGen)
11+
add_mlir_library(
12+
MQTRefToQIR
13+
${CONVERSION_SOURCES}
14+
DEPENDS
15+
MQTRefToQIRIncGen
16+
LINK_LIBS
17+
MLIRMQTRef
18+
MLIRMemRefDialect
19+
MLIRTransforms
20+
MLIRLLVMDialect
21+
MLIRFuncToLLVM
22+
MLIRReconcileUnrealizedCasts)

mlir/lib/Conversion/QIRToMQTRef/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,13 @@
88

99
file(GLOB CONVERSION_SOURCES *.cpp)
1010

11-
add_mlir_library(QIRToMQTRef ${CONVERSION_SOURCES} DEPENDS QIRToMQTRefIncGen)
11+
add_mlir_library(
12+
QIRToMQTRef
13+
${CONVERSION_SOURCES}
14+
DEPENDS
15+
QIRToMQTRefIncGen
16+
LINK_LIBS
17+
MLIRMQTRef
18+
MLIRMemRefDialect
19+
MLIRTransforms
20+
MLIRLLVMDialect)

mlir/lib/Dialect/MQTOpt/IR/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
#
77
# Licensed under the MIT License
88

9-
add_mlir_dialect_library(MLIRMQTOpt MQTOptOps.cpp DEPENDS MLIRMQTOptOpsIncGen
10-
MLIRMQTOptInterfacesIncGen)
9+
add_mlir_dialect_library(
10+
MLIRMQTOpt
11+
${MQT_CORE_MLIR_LIBRARY_TYPE}
12+
MQTOptOps.cpp
13+
DEPENDS
14+
MLIRMQTOptOpsIncGen
15+
MLIRMQTOptInterfacesIncGen
16+
LINK_LIBS
17+
MLIRIR
18+
MLIRInferTypeOpInterface)
1119
# collect header files
1220
file(GLOB_RECURSE IR_HEADERS_SOURCE "${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/MQTOpt/IR/*.h")
1321
file(GLOB_RECURSE IR_HEADERS_BUILD "${MQT_MLIR_BUILD_INCLUDE_DIR}/mlir/Dialect/MQTOpt/IR/*.inc")

mlir/lib/Dialect/MQTRef/IR/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
#
77
# Licensed under the MIT License
88

9-
add_mlir_dialect_library(MLIRMQTRef MQTRefOps.cpp DEPENDS MLIRMQTRefOpsIncGen
10-
MLIRMQTRefInterfacesIncGen)
9+
add_mlir_dialect_library(
10+
MLIRMQTRef
11+
${MQT_CORE_MLIR_LIBRARY_TYPE}
12+
MQTRefOps.cpp
13+
DEPENDS
14+
MLIRMQTRefOpsIncGen
15+
MLIRMQTRefInterfacesIncGen
16+
LINK_LIBS
17+
MLIRIR
18+
MLIRInferTypeOpInterface)
1119

1220
# collect header files
1321
file(GLOB_RECURSE IR_HEADERS_SOURCE "${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/MQTRef/IR/*.h")

mlir/lib/Dialect/MQTRef/Translation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_compile_options(-fexceptions)
1010

1111
add_mlir_library(
1212
MLIRMQTRefTranslation
13+
${MQT_CORE_MLIR_LIBRARY_TYPE}
1314
ImportQuantumComputation.cpp
1415
LINK_LIBS
1516
MLIRArithDialect

0 commit comments

Comments
 (0)