Skip to content

Commit

Permalink
Restore Python install behavior from before D128230.
Browse files Browse the repository at this point in the history
In D128230, we accidentally moved the install for Python sources outside of the loop, having one install() per group of files. While it would be nice if we could do this, it means that we flatten the relative directory tree and every source ends up in the root. The right way to do this is to use FILE_SETS, which preserve the relative directory tree, but they are not available until CMake 3.23.

Differential Revision: https://reviews.llvm.org/D129434
  • Loading branch information
stellaraccident committed Jul 10, 2022
1 parent 13ae213 commit 2aa6d56
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions mlir/cmake/modules/AddMLIRPython.cmake
Expand Up @@ -567,15 +567,21 @@ function(add_mlir_python_sources_target name)
COMMAND "${CMAKE_COMMAND}" -E ${_link_or_copy}
"${_src_path}" "${_dest_path}"
)
if(ARG_INSTALL_DIR)
# We have to install each file individually because we need to preserve
# the relative directory structure in the install destination.
# As an example, ${_source_relative_path} may be dialects/math.py
# which would be transformed to ${ARG_INSTALL_DIR}/dialects
# here. This could be moved outside of the loop and cleaned up
# if we used FILE_SETS (introduced in CMake 3.23).
get_filename_component(_install_destination "${ARG_INSTALL_DIR}/${_source_relative_path}" DIRECTORY)
install(
FILES ${_src_path}
DESTINATION "${_install_destination}"
COMPONENT ${ARG_INSTALL_COMPONENT}
)
endif()
endforeach()

if(ARG_INSTALL_DIR)
install(
FILES ${_src_paths}
DESTINATION "${ARG_INSTALL_DIR}"
COMPONENT ${ARG_INSTALL_COMPONENT}
)
endif()
endforeach()
endfunction()

Expand Down

0 comments on commit 2aa6d56

Please sign in to comment.