4 changes: 1 addition & 3 deletions mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ add_mlir_dialect_library(MLIRLinalgTransforms

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Linalg

DEPENDS
intrinsics_gen
)

add_dependencies(MLIRLinalgTransforms
MLIRLinalgTransformPatternsIncGen
)
target_link_libraries(MLIRLinalgTransforms
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/LoopOps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ add_mlir_dialect_library(MLIRLoopOps

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps
)
add_dependencies(MLIRLoopOps

DEPENDS
MLIRLoopLikeInterfaceIncGen
MLIRLoopOpsIncGen
)
Expand Down
6 changes: 5 additions & 1 deletion mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ add_mlir_dialect_library(MLIRLoopOpsTransforms
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LoopOps
)

target_link_libraries(MLIRLoopOpsTransforms
PUBLIC
MLIRAffineOps
MLIRIR
MLIRPass
MLIRLoopOps
MLIRStandardOps
MLIRSupport
LLVMSupport
)
8 changes: 5 additions & 3 deletions mlir/lib/Dialect/OpenMP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ add_mlir_dialect_library(MLIROpenMP

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/OpenMP
)

add_dependencies(MLIROpenMP MLIROpenMPOpsIncGen)
DEPENDS
MLIROpenMPOpsIncGen
)
target_link_libraries(MLIROpenMP
PUBLIC
MLIRIR)
MLIRIR
)
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/QuantOps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ add_mlir_dialect_library(MLIRQuantOps

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/QuantOps
)
add_dependencies(MLIRQuantOps

DEPENDS
MLIRQuantOpsIncGen
)
target_link_libraries(MLIRQuantOps
Expand Down
9 changes: 4 additions & 5 deletions mlir/lib/Dialect/SPIRV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@ add_mlir_dialect_library(MLIRSPIRV

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
)

add_dependencies(MLIRSPIRV
MLIRControlFlowInterfacesIncGen
MLIRSPIRVAvailabilityIncGen
MLIRSPIRVCanonicalizationIncGen
MLIRSPIRVEnumAvailabilityIncGen
MLIRSPIRVEnumsIncGen
MLIRSPIRVOpsIncGen
MLIRSPIRVOpUtilsGen
MLIRSPIRVTargetAndABIIncGen)

MLIRSPIRVTargetAndABIIncGen
)
target_link_libraries(MLIRSPIRV
PUBLIC
MLIRIR
MLIRParser
MLIRSupport
MLIRTransforms)
MLIRTransforms
)

add_subdirectory(Serialization)
add_subdirectory(Transforms)
10 changes: 5 additions & 5 deletions mlir/lib/Dialect/SPIRV/Serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ add_mlir_dialect_library(MLIRSPIRVSerialization

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
)

add_dependencies(MLIRSPIRVSerialization
MLIRSPIRVSerializationGen)

DEPENDS
MLIRSPIRVSerializationGen
)
target_link_libraries(MLIRSPIRVSerialization
PUBLIC
MLIRIR
MLIRSPIRV
MLIRSupport
MLIRTranslation)
MLIRTranslation
)
5 changes: 3 additions & 2 deletions mlir/lib/Dialect/StandardOps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ add_mlir_dialect_library(MLIRStandardOps

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/StandardOps
)
add_dependencies(MLIRStandardOps

DEPENDS
MLIRCallOpInterfacesIncGen
MLIRControlFlowInterfacesIncGen
MLIRStandardOpsIncGen
)
target_link_libraries(MLIRStandardOps
PUBLIC
MLIRControlFlowAnalysis
MLIREDSC
MLIRIR
LLVMSupport
Expand Down
12 changes: 7 additions & 5 deletions mlir/lib/Dialect/VectorOps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ add_mlir_dialect_library(MLIRVectorOps

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/VectorOps
)

add_dependencies(MLIRVectorOps MLIRVectorOpsIncGen)
add_dependencies(MLIRVectorOps MLIRVectorTransformPatternsIncGen)

DEPENDS
MLIRVectorOpsIncGen
MLIRVectorTransformPatternsIncGen
)
target_link_libraries(MLIRVectorOps
PUBLIC
MLIREDSC
MLIRIR
MLIRStandardOps
MLIRAffineOps
MLIRLoopOps
MLIRLoopAnalysis)
MLIRLoopAnalysis
)
4 changes: 2 additions & 2 deletions mlir/lib/EDSC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(LLVM_OPTIONAL_SOURCES
CoreAPIs.cpp
)

add_llvm_library(MLIREDSC
add_mlir_library(MLIREDSC
Builders.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -16,7 +16,7 @@ target_link_libraries(MLIREDSC
MLIRSupport
)

add_llvm_library(MLIREDSCInterface
add_mlir_library(MLIREDSCInterface
CoreAPIs.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/ExecutionEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(LLVM_OPTIONAL_SOURCES
)

llvm_map_components_to_libnames(outlibs "nativecodegen" "IPO")
add_llvm_library(MLIRExecutionEngine
add_mlir_library(MLIRExecutionEngine
ExecutionEngine.cpp
OptUtils.cpp

Expand Down
9 changes: 5 additions & 4 deletions mlir/lib/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
file(GLOB globbed *.c *.cpp)
add_llvm_library(MLIRIR
add_mlir_library(MLIRIR
${globbed}

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/IR
)
add_dependencies(MLIRIR

DEPENDS
MLIRCallOpInterfacesIncGen
MLIROpAsmInterfacesIncGen
)
target_link_libraries(MLIRIR
PUBLIC
MLIRSupport
LLVMSupport)
LLVMSupport
)
2 changes: 1 addition & 1 deletion mlir/lib/Parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRParser
add_mlir_library(MLIRParser
Lexer.cpp
Parser.cpp
Token.cpp
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Pass/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file(GLOB globbed *.c *.cpp)
add_llvm_library(MLIRPass
add_mlir_library(MLIRPass
${globbed}

ADDITIONAL_HEADER_DIRS
Expand Down
13 changes: 8 additions & 5 deletions mlir/lib/Quantizer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Support.
add_llvm_library(MLIRQuantizerSupport
add_mlir_library(MLIRQuantizerSupport
Support/Configuration.cpp
Support/ConstraintAnalysisGraph.cpp
Support/Metadata.cpp
Expand All @@ -21,25 +21,28 @@ target_link_libraries(MLIRQuantizerSupport
)

# Configurations.
add_llvm_library(MLIRQuantizerFxpMathConfig
add_mlir_library(MLIRQuantizerFxpMathConfig
Configurations/FxpMathConfig.cpp

ADDITIONAL_HEADER_DIRS
)

add_dependencies(MLIRQuantizerFxpMathConfig
DEPENDS
MLIRFxpMathOpsIncGen
)

target_link_libraries(MLIRQuantizerFxpMathConfig
PUBLIC
MLIRIR
MLIRFxpMathOps
MLIRQuantOps
MLIRQuantizerSupport
MLIRStandardOps
MLIRSupport
LLVMSupport
)

# Transforms.
add_llvm_library(MLIRQuantizerTransforms
add_mlir_library(MLIRQuantizerTransforms
Transforms/AddDefaultStatsTestPass.cpp
Transforms/InferQuantizedTypesPass.cpp
Transforms/RemoveInstrumentationPass.cpp
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(LLVM_OPTIONAL_SOURCES
TranslateClParser.cpp
)

add_llvm_library(MLIRSupport
add_mlir_library(MLIRSupport
FileUtilities.cpp
StorageUniquer.cpp
ToolUtilities.cpp
Expand All @@ -20,7 +20,7 @@ target_link_libraries(MLIRSupport
LLVMSupport
${LLVM_PTHREAD_LIB})

add_llvm_library(MLIROptLib
add_mlir_library(MLIROptLib
MlirOptMain.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -34,7 +34,7 @@ target_link_libraries(MLIROptLib
MLIRSupport
)

add_llvm_library(MLIRTranslateClParser
add_mlir_library(MLIRTranslateClParser
TranslateClParser.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
23 changes: 16 additions & 7 deletions mlir/lib/Target/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRTargetLLVMIRModuleTranslation
add_mlir_library(MLIRTargetLLVMIRModuleTranslation
LLVMIR/DebugTranslation.cpp
LLVMIR/ModuleTranslation.cpp

Expand All @@ -9,9 +9,15 @@ add_llvm_library(MLIRTargetLLVMIRModuleTranslation
)
target_link_libraries(MLIRTargetLLVMIRModuleTranslation
PUBLIC
MLIRLLVMIR LLVMCore LLVMIRReader LLVMSupport LLVMTransformUtils
MLIRTranslation)
add_llvm_library(MLIRTargetLLVMIR
MLIRLLVMIR
LLVMCore
LLVMIRReader
LLVMSupport
LLVMTransformUtils
MLIRTranslation
)

add_mlir_library(MLIRTargetLLVMIR
LLVMIR/ConvertFromLLVMIR.cpp
LLVMIR/ConvertToLLVMIR.cpp

Expand All @@ -20,8 +26,10 @@ add_llvm_library(MLIRTargetLLVMIR
)
target_link_libraries(MLIRTargetLLVMIR
PUBLIC
MLIRTargetLLVMIRModuleTranslation)
add_llvm_library(MLIRTargetNVVMIR
MLIRTargetLLVMIRModuleTranslation
)

add_mlir_library(MLIRTargetNVVMIR
LLVMIR/ConvertToNVVMIR.cpp

ADDITIONAL_HEADER_DIRS
Expand All @@ -37,7 +45,8 @@ target_link_libraries(MLIRTargetNVVMIR
MLIRNVVMIR
MLIRTargetLLVMIRModuleTranslation
)
add_llvm_library(MLIRTargetROCDLIR

add_mlir_library(MLIRTargetROCDLIR
LLVMIR/ConvertToROCDLIR.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
9 changes: 5 additions & 4 deletions mlir/lib/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(Utils)

add_llvm_library(MLIRTransforms
add_mlir_library(MLIRTransforms
AffineDataCopyGeneration.cpp
AffineLoopInvariantCodeMotion.cpp
Canonicalizer.cpp
Expand All @@ -26,11 +26,12 @@ add_llvm_library(MLIRTransforms

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms
)

add_dependencies(MLIRTransforms
DEPENDS
MLIRLoopLikeInterfaceIncGen
MLIRStandardOpsIncGen)
MLIRStandardOpsIncGen
)

target_link_libraries(MLIRTransforms
PUBLIC
MLIRAffineOps
Expand Down
6 changes: 4 additions & 2 deletions mlir/lib/Transforms/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRTransformUtils
add_mlir_library(MLIRTransformUtils
FoldUtils.cpp
GreedyPatternRewriteDriver.cpp
InliningUtils.cpp
Expand All @@ -9,9 +9,11 @@ add_llvm_library(MLIRTransformUtils

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms

DEPENDS
MLIRStandardOpsIncGen
)

add_dependencies(MLIRTransformUtils MLIRStandardOpsIncGen)
target_link_libraries(MLIRTransformUtils
PUBLIC
MLIRAffineOps
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Translation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRTranslation
add_mlir_library(MLIRTranslation
Translation.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
1 change: 1 addition & 0 deletions mlir/test/SDBM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target_link_libraries(mlir-sdbm-api-test
PRIVATE
MLIRIR
MLIRSDBM
MLIRSupport
LLVMCore
LLVMSupport
)
Expand Down
6 changes: 4 additions & 2 deletions mlir/test/lib/TestDialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ add_public_tablegen_target(MLIRTestOpsIncGen)
add_llvm_library(MLIRTestDialect
TestDialect.cpp
TestPatterns.cpp
)
add_dependencies(MLIRTestDialect

DEPENDS
MLIRControlFlowInterfacesIncGen
MLIRTestOpsIncGen
MLIRTypeInferOpInterfaceIncGen
)
target_link_libraries(MLIRTestDialect
PUBLIC
MLIRAnalysis
MLIRDialect
MLIRIR
MLIRLinalgTransforms
MLIRPass
MLIRStandardOps
MLIRTransforms
MLIRTransformUtils
LLVMSupport
Expand Down
9 changes: 6 additions & 3 deletions mlir/test/lib/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ add_llvm_library(MLIRTestTransforms

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms

DEPENDS
MLIRStandardOpsIncGen
MLIRTestLinalgTransformPatternsIncGen
MLIRTestVectorTransformPatternsIncGen
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../TestDialect)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../TestDialect)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../DeclarativeTransforms)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../DeclarativeTransforms)
add_dependencies(MLIRTestTransforms MLIRStandardOpsIncGen)
add_dependencies(MLIRTestTransforms MLIRTestLinalgTransformPatternsIncGen)
add_dependencies(MLIRTestTransforms MLIRTestVectorTransformPatternsIncGen)

target_link_libraries(MLIRTestTransforms
PUBLIC
MLIRAffineOps
Expand Down
1 change: 1 addition & 0 deletions mlir/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ add_subdirectory(mlir-opt)
add_subdirectory(mlir-tblgen)
add_subdirectory(mlir-translate)
add_subdirectory(mlir-vulkan-runner)
add_subdirectory(mlir-shlib)
5 changes: 4 additions & 1 deletion mlir/tools/mlir-cpu-runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ target_link_libraries(mlir-cpu-runner PRIVATE
MLIRSupport
LLVMCore
LLVMSupport
)
LLVMX86CodeGen
LLVMX86Desc
LLVMX86Info
)
6 changes: 4 additions & 2 deletions mlir/tools/mlir-cuda-runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ if(MLIR_CUDA_RUNNER_ENABLED)

add_llvm_tool(mlir-cuda-runner
mlir-cuda-runner.cpp
)
add_dependencies(mlir-cuda-runner cuda-runtime-wrappers)

DEPENDS
cuda-runtime-wrappers
)
target_include_directories(mlir-cuda-runner
PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
Expand Down
1 change: 1 addition & 0 deletions mlir/tools/mlir-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(LLVM_OPTIONAL_SOURCES

set(LIB_LIBS
MLIRAnalysis
MLIRIR
MLIRLLVMIR
MLIROptLib
MLIRParser
Expand Down
42 changes: 42 additions & 0 deletions mlir/tools/mlir-shlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Building libmlir-cpp.so fails if LLVM_ENABLE_PIC=Off
if (NOT LLVM_ENABLE_PIC)
return()
endif()

# Building libmlir-cpp.so may not work on MSVC
if (MSVC)
return()
endif()

get_property(mlir_libs GLOBAL PROPERTY MLIR_ALL_LIBS)
list(REMOVE_DUPLICATES mlir_libs)

foreach (lib ${mlir_libs})
if(XCODE)
# Xcode doesn't support object libraries, so we have to trick it into
# linking the static libraries instead.
list(APPEND _DEPS "-force_load" ${lib})
else()
list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
endif()
list(APPEND _DEPS $<TARGET_PROPERTY:${lib},LINK_LIBRARIES>)
endforeach ()

if(MLIR_LINK_MLIR_DYLIB)
set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
endif()

# libMLIR.so depends on LLVM components. To avoid multiple
# copies of those LLVM components, libMLIR.so depends on libLLVM.so.
# This probably won't work if some LLVM components are not included
# in libLLVM.so.
if(LLVM_BUILD_LLVM_DYLIB)
add_llvm_library(MLIR
SHARED
${INSTALL_WITH_TOOLCHAIN}

mlir-shlib.cpp
)
target_link_libraries(MLIR PRIVATE LLVM ${LLVM_PTHREAD_LIB})
whole_archive_link(MLIR ${mlir_libs})
endif()
1 change: 1 addition & 0 deletions mlir/tools/mlir-shlib/mlir-shlib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Intentionally empty source file to make CMake happy