Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Update CMakeLists.txt for shared library build
Browse files Browse the repository at this point in the history
There are several circular dependencies between libraries.  These
are explicitly marked as STATIC.  Note that add_llvm_library is redundant
with add_dependencies, so we don't have to have libraries in both places.
  • Loading branch information
stephenneuendorffer committed Sep 11, 2019
1 parent 797757b commit 6beae9b
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 45 deletions.
7 changes: 4 additions & 3 deletions examples/Linalg/Linalg1/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(LIBS
MLIRAnalysis
MLIRControlFlowToCFG
MLIREDSC
MLIRLinalg
MLIRLLVMIR
MLIRParser
MLIRPass
Expand All @@ -26,13 +27,13 @@ set(LIBS
MLIRTransforms
)

add_llvm_library(Linalg1LLVMConversion
add_llvm_library(Linalg1LLVMConversion STATIC
ConvertToLLVMDialect.cpp
)
target_link_libraries(Linalg1LLVMConversion PUBLIC MLIRLLVMIR
MLIRControlFlowToCFG MLIRStandardOps)
Linalg1 MLIRControlFlowToCFG MLIRStandardOps MLIRStandardToLLVM MLIRLinalg)

add_llvm_library(Linalg1
add_llvm_library(Linalg1 STATIC
Analysis.cpp
SliceOp.cpp
ViewOp.cpp
Expand Down
3 changes: 1 addition & 2 deletions lib/Analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ add_llvm_library(MLIRAnalysis STATIC
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Analysis
)
add_dependencies(MLIRAnalysis MLIRAffineOps MLIRLoopOps)
target_link_libraries(MLIRAnalysis MLIRAffineOps MLIRLoopOps)
target_link_libraries(MLIRAnalysis MLIRAffineOps MLIRLoopOps MLIRPass)
2 changes: 2 additions & 0 deletions lib/Conversion/GPUToNVVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ target_link_libraries(MLIRGPUtoNVVMTransforms
MLIRGPU
MLIRLLVMIR
MLIRNVVMIR
MLIRStandardToLLVM
MLIRTransforms
MLIRPass
)
1 change: 1 addition & 0 deletions lib/Conversion/StandardToSPIRV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target_link_libraries(MLIRSPIRVConversion
MLIRPass
MLIRSPIRV
MLIRSupport
MLIRTransforms
MLIRTransformUtils
MLIRSPIRV
MLIRStandardOps
Expand Down
1 change: 1 addition & 0 deletions lib/Conversion/VectorToLLVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_llvm_library(MLIRVectorToLLVM
)
set(LIBS
MLIRLLVMIR
MLIRStandardToLLVM
MLIRTransforms
LLVMCore
LLVMSupport
Expand Down
3 changes: 1 addition & 2 deletions lib/Dialect/AffineOps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRAffineOps
add_llvm_library(MLIRAffineOps STATIC
AffineOps.cpp
DialectRegistration.cpp

Expand All @@ -7,4 +7,3 @@ add_llvm_library(MLIRAffineOps
)
add_dependencies(MLIRAffineOps MLIRAffineOpsIncGen MLIRIR MLIRStandardOps)
target_link_libraries(MLIRAffineOps MLIRIR MLIRStandardOps)

17 changes: 10 additions & 7 deletions lib/Dialect/FxpMathOps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ add_llvm_library(MLIRFxpMathOps
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/FxpMathOps
)
add_dependencies(MLIRFxpMathOps
MLIRFxpMathOpsIncGen
MLIRQuantOps
MLIRIR
MLIRPass
MLIRSupport
MLIRStandardOps)
add_dependencies(
MLIRFxpMathOps
MLIRFxpMathOpsIncGen)
target_link_libraries(
MLIRFxpMathOps
MLIRQuantOps
MLIRIR
MLIRPass
MLIRSupport
MLIRStandardOps)
2 changes: 1 addition & 1 deletion lib/Dialect/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ add_llvm_library(MLIRGPU
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/GPU
)
add_dependencies(MLIRGPU MLIRGPUOpsIncGen MLIRIR LLVMSupport)
target_link_libraries(MLIRGPU MLIRIR MLIRStandardOps LLVMSupport)
target_link_libraries(MLIRGPU MLIRIR MLIRPass MLIRStandardOps LLVMSupport)
4 changes: 2 additions & 2 deletions lib/Dialect/LLVMIR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_llvm_library(MLIRLLVMIR
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
)
add_dependencies(MLIRLLVMIR MLIRLLVMOpsIncGen MLIRLLVMConversionsIncGen LLVMAsmParser LLVMCore LLVMSupport)
target_link_libraries(MLIRLLVMIR LLVMAsmParser LLVMCore LLVMSupport)
target_link_libraries(MLIRLLVMIR MLIRIR LLVMAsmParser LLVMCore LLVMSupport)

add_llvm_library(MLIRNVVMIR
IR/NVVMDialect.cpp
Expand All @@ -14,4 +14,4 @@ add_llvm_library(MLIRNVVMIR
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
)
add_dependencies(MLIRNVVMIR MLIRNVVMOpsIncGen MLIRNVVMConversionsIncGen LLVMAsmParser LLVMCore LLVMSupport)
target_link_libraries(MLIRNVVMIR LLVMAsmParser LLVMCore LLVMSupport)
target_link_libraries(MLIRNVVMIR MLIRLLVMIR MLIRIR LLVMAsmParser LLVMCore LLVMSupport)
8 changes: 6 additions & 2 deletions lib/Dialect/Linalg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRLinalg
add_llvm_library(MLIRLinalg STATIC
LinalgRegistration.cpp
Analysis/DependenceAnalysis.cpp
IR/LinalgOps.cpp
Expand All @@ -17,8 +17,12 @@ add_llvm_library(MLIRLinalg

add_dependencies(MLIRLinalg

MLIRAffineOps
MLIRLinalgOpsIncGen
MLIRLinalgLibraryOpsIncGen
)
target_link_libraries(MLIRLinalg

MLIRAffineOps
MLIRIR
MLIRStandardToLLVM
)
6 changes: 3 additions & 3 deletions lib/Dialect/LoopOps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
file(GLOB globbed *.c *.cpp)
add_llvm_library(MLIRLoopOps
add_llvm_library(MLIRLoopOps STATIC
${globbed}

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps
)
add_dependencies(MLIRLoopOps MLIRLoopOpsIncGen MLIRStandardOps LLVMSupport)
target_link_libraries(MLIRLoopOps LLVMSupport)
add_dependencies(MLIRLoopOps MLIRLoopOpsIncGen MLIRStandardOps MLIRIR LLVMSupport)
target_link_libraries(MLIRLoopOps MLIRStandardOps MLIRIR LLVMSupport)
2 changes: 2 additions & 0 deletions lib/Dialect/QuantOps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ add_dependencies(MLIRQuantOps
MLIRQuantOpsIncGen
MLIRSupport
MLIRStandardOps)

target_link_libraries(MLIRQuantOps MLIRIR MLIRPass MLIRParser MLIRSupport MLIRTransforms MLIRAnalysis MLIRStandardOps LLVMSupport)
3 changes: 2 additions & 1 deletion lib/Dialect/SPIRV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_dependencies(MLIRSPIRV
target_link_libraries(MLIRSPIRV
MLIRIR
MLIRParser
MLIRSupport)
MLIRSupport
MLIRTranslation)

add_subdirectory(Serialization)
3 changes: 2 additions & 1 deletion lib/Dialect/SPIRV/Serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ add_dependencies(MLIRSPIRVSerialization
target_link_libraries(MLIRSPIRVSerialization
MLIRIR
MLIRSPIRV
MLIRSupport)
MLIRSupport
MLIRTranslation)
4 changes: 2 additions & 2 deletions lib/Dialect/StandardOps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
file(GLOB globbed *.c *.cpp)
add_llvm_library(MLIRStandardOps
add_llvm_library(MLIRStandardOps STATIC
${globbed}

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/StandardOps
)
add_dependencies(MLIRStandardOps MLIRStandardOpsIncGen LLVMSupport)
target_link_libraries(MLIRStandardOps LLVMSupport)
target_link_libraries(MLIRStandardOps MLIRIR MLIRParser LLVMSupport)
8 changes: 8 additions & 0 deletions lib/ExecutionEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ target_link_libraries(MLIRExecutionEngine

MLIRLLVMIR
MLIRTargetLLVMIR
Linalg1LLVMConversion
LLVMAggressiveInstCombine
LLVMAnalysis
LLVMBitReader
LLVMBitWriter
LLVMExecutionEngine
LLVMInstCombine
LLVMOrcJIT
LLVMMC
LLVMScalarOpts
LLVMSupport
LLVMTarget
LLVMTransformUtils
LLVMVectorize

${outlibs})
2 changes: 1 addition & 1 deletion lib/Parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_llvm_library(MLIRParser
add_llvm_library(MLIRParser STATIC
Lexer.cpp
Parser.cpp
Token.cpp
Expand Down
4 changes: 2 additions & 2 deletions lib/Pass/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
file(GLOB globbed *.c *.cpp)
add_llvm_library(MLIRPass
add_llvm_library(MLIRPass STATIC
${globbed}

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Pass
)
add_dependencies(MLIRPass MLIRAnalysis MLIRIR LLVMSupport)
add_dependencies(MLIRPass MLIRIR LLVMSupport)
target_link_libraries(MLIRPass MLIRAnalysis MLIRIR LLVMSupport)
22 changes: 14 additions & 8 deletions lib/Quantizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@ add_llvm_library(MLIRQuantizerSupport

ADDITIONAL_HEADER_DIRS
)
add_dependencies(MLIRQuantizerSupport
MLIRIR
MLIRQuantOps
MLIRSupport
MLIRStandardOps)
target_link_libraries(
MLIRQuantizerSupport
MLIRIR
MLIRQuantOps
MLIRSupport
MLIRStandardOps)

# Configurations.
add_llvm_library(MLIRQuantizerFxpMathConfig
Configurations/FxpMathConfig.cpp

ADDITIONAL_HEADER_DIRS
)
add_dependencies(MLIRQuantizerFxpMathConfig
MLIRFxpMathOpsIncGen
MLIRQuantizerSupport)
add_dependencies(
MLIRQuantizerFxpMathConfig
MLIRFxpMathOpsIncGen)
target_link_libraries(
MLIRQuantizerFxpMathConfig
MLIRFxpMathOps
MLIRIR
MLIRQuantizerSupport)

# Transforms.
add_llvm_library(MLIRQuantizerTransforms
Expand Down
6 changes: 3 additions & 3 deletions lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ add_llvm_library(MLIRSupport
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Support
)
target_link_libraries(MLIRSupport LLVMSupport)
target_link_libraries(MLIRSupport Threads::Threads LLVMSupport)

add_llvm_library(MLIROptMain
MlirOptMain.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Support
)
target_link_libraries(MLIROptMain LLVMSupport)
target_link_libraries(MLIROptMain MLIRIR MLIRParser LLVMSupport)

add_llvm_library(MLIRTranslateClParser
TranslateClParser.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Support
)
target_link_libraries(MLIRTranslateClParser LLVMSupport)
target_link_libraries(MLIRTranslateClParser MLIRTranslation MLIRIR MLIRAnalysis MLIRParser LLVMSupport)

add_llvm_library(MLIRJitRunner
JitRunner.cpp
Expand Down
1 change: 1 addition & 0 deletions lib/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ add_dependencies(MLIRTransforms MLIRStandardOpsIncGen)
target_link_libraries(MLIRTransforms
MLIRAffineOps
MLIRAnalysis
MLIREDSC
MLIRLoopOps
MLIRPass
MLIRTransformUtils
Expand Down
4 changes: 2 additions & 2 deletions test/lib/TestDialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ add_llvm_library(MLIRTestDialect
)
add_dependencies(MLIRTestDialect
MLIRTestOpsIncGen
MLIRIR
LLVMSupport
)
target_link_libraries(MLIRTestDialect
MLIRDialect
MLIRIR
MLIRPass
MLIRTransforms
LLVMSupport
)
9 changes: 6 additions & 3 deletions tools/mlir-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ set(LLVM_OPTIONAL_SOURCES
)

set(LIB_LIBS
Linalg1LLVMConversion
MLIRAnalysis
MLIRIR
MLIRLLVMIR
MLIROptMain
MLIRParser
MLIRPass
MLIRTransforms
MLIRQuantizerSupport
MLIRSupport
MLIRTransforms
)
add_llvm_library(MLIRMlirOptLib
mlir-opt.cpp
)
target_link_libraries(MLIRMlirOptLib ${LIB_LIBS})
target_link_libraries(MLIRMlirOptLib ${LIB_LIBS} MLIRIR)

set(LIBS
MLIRAffineOps
Expand All @@ -40,7 +44,6 @@ set(LIBS
MLIRStandardToLLVM
MLIRTransforms
MLIRTestDialect
MLIRTestPass
MLIRTestTransforms
MLIRSupport
MLIRVectorOps
Expand Down

0 comments on commit 6beae9b

Please sign in to comment.