1 # Building libmlir-cpp.so fails if LLVM_ENABLE_PIC=Off
2 if (NOT LLVM_ENABLE_PIC)
6 # Building libmlir-cpp.so may not work on MSVC
11 get_property(mlir_libs GLOBAL PROPERTY MLIR_STATIC_LIBS)
12 get_property(mlir_llvm_link_components GLOBAL PROPERTY MLIR_LLVM_LINK_COMPONENTS)
13 list(REMOVE_DUPLICATES mlir_libs)
14 list(REMOVE_DUPLICATES mlir_llvm_link_components)
16 foreach (lib ${mlir_libs})
18 # Xcode doesn't support object libraries, so we have to trick it into
19 # linking the static libraries instead.
20 list(APPEND _DEPS "-force_load" ${lib})
22 list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
24 # libClang needs this, but it causes problems for MLIR (probably
25 # because we use public library dependencies within MLIR.)
26 # list(APPEND _DEPS $<TARGET_PROPERTY:${lib},LINK_LIBRARIES>)
29 if(MLIR_LINK_MLIR_DYLIB)
30 set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
33 if(LLVM_BUILD_LLVM_DYLIB)
38 ${INSTALL_WITH_TOOLCHAIN}
45 ${mlir_llvm_link_components}
47 target_link_libraries(MLIR PRIVATE ${LLVM_PTHREAD_LIB})
50 #message("Libraries included in libMLIR.so: ${mlir_libs}")
51 #message("LLVM Components included in libMLIR.so: ${mlir_llvm_link_components}")
53 mlir_check_all_link_libraries(MLIR)