[mlir][cmake] Fix MLIR shared library installation (#152195)
When `LLVM_INSTALL_TOOLCHAIN_ONLY=ON`, the MLIR shared library (`libMLIR*`) is not installed even though it is built with the `INSTALL_WITH_TOOLCHAIN` argument to the `add_mlir_library` cmake function. This patch ensures that `libMLIR*` is installed when `LLVM_INSTALL_TOOLCHAIN_ONLY=ON`. Patch verified [here](https://github.com/llvm/llvm-project/issues/151247#issuecomment-3156387055). fixes #151247
This commit is contained in:
parent
0bcf45ea34
commit
69d0bd56ad
@ -388,6 +388,9 @@ function(add_mlir_library name)
|
||||
|
||||
if(TARGET ${name})
|
||||
target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
|
||||
if(ARG_INSTALL_WITH_TOOLCHAIN)
|
||||
set_target_properties(${name} PROPERTIES MLIR_INSTALL_WITH_TOOLCHAIN TRUE)
|
||||
endif()
|
||||
if(NOT ARG_DISABLE_INSTALL)
|
||||
add_mlir_library_install(${name})
|
||||
endif()
|
||||
@ -617,28 +620,29 @@ endfunction(add_mlir_aggregate)
|
||||
# This is usually done as part of add_mlir_library but is broken out for cases
|
||||
# where non-standard library builds can be installed.
|
||||
function(add_mlir_library_install name)
|
||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
||||
get_target_export_arg(${name} MLIR export_to_mlirtargets UMBRELLA mlir-libraries)
|
||||
install(TARGETS ${name}
|
||||
COMPONENT ${name}
|
||||
${export_to_mlirtargets}
|
||||
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
# Note that CMake will create a directory like:
|
||||
# objects-${CMAKE_BUILD_TYPE}/obj.LibName
|
||||
# and put object files there.
|
||||
OBJECTS DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
)
|
||||
get_target_property(_install_with_toolchain ${name} MLIR_INSTALL_WITH_TOOLCHAIN)
|
||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR _install_with_toolchain)
|
||||
get_target_export_arg(${name} MLIR export_to_mlirtargets UMBRELLA mlir-libraries)
|
||||
install(TARGETS ${name}
|
||||
COMPONENT ${name}
|
||||
${export_to_mlirtargets}
|
||||
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
# Note that CMake will create a directory like:
|
||||
# objects-${CMAKE_BUILD_TYPE}/obj.LibName
|
||||
# and put object files there.
|
||||
OBJECTS DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
)
|
||||
|
||||
if (NOT LLVM_ENABLE_IDE)
|
||||
add_llvm_install_targets(install-${name}
|
||||
DEPENDS ${name}
|
||||
COMPONENT ${name})
|
||||
if (NOT LLVM_ENABLE_IDE)
|
||||
add_llvm_install_targets(install-${name}
|
||||
DEPENDS ${name}
|
||||
COMPONENT ${name})
|
||||
endif()
|
||||
set_property(GLOBAL APPEND PROPERTY MLIR_ALL_LIBS ${name})
|
||||
set_property(GLOBAL APPEND PROPERTY MLIR_EXPORTS ${name})
|
||||
endif()
|
||||
set_property(GLOBAL APPEND PROPERTY MLIR_ALL_LIBS ${name})
|
||||
endif()
|
||||
set_property(GLOBAL APPEND PROPERTY MLIR_EXPORTS ${name})
|
||||
endfunction()
|
||||
|
||||
# Declare an mlir library which is part of the public C-API.
|
||||
|
Loading…
x
Reference in New Issue
Block a user