[Clang][SME2] Fix PSEL builtin predicates (#77097)
[llvm-project.git] / mlir / tools / mlir-shlib / CMakeLists.txt
blob32fe833cee4ea782ac7fe36be2e85b3303ae6e5b
1 # Building libmlir-cpp.so fails if LLVM_ENABLE_PIC=Off
2 if (NOT LLVM_ENABLE_PIC)
3   return()
4 endif()
6 # Building libmlir-cpp.so may not work on MSVC
7 if (MSVC)
8   return()
9 endif()
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})
17   if(XCODE)
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})
21   else()
22     list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
23   endif()
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>)
27 endforeach ()
29 if(MLIR_LINK_MLIR_DYLIB)
30   set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
31 endif()
33 if(LLVM_BUILD_LLVM_DYLIB)
34   add_mlir_library(
35     MLIR
36     SHARED
37     ${INSTALL_WITH_TOOLCHAIN}
38     mlir-shlib.cpp
39     ${_OBJECTS}
40     LINK_LIBS
41     ${_DEPS}
43     LINK_COMPONENTS
44     ${mlir_llvm_link_components}
45   )
46   target_link_libraries(MLIR PRIVATE ${LLVM_PTHREAD_LIB})
47 endif()
49 #message("Libraries included in libMLIR.so: ${mlir_libs}")
50 #message("LLVM Components included in libMLIR.so: ${mlir_llvm_link_components}")
52 mlir_check_all_link_libraries(MLIR)