[Mlir-commits] [mlir] 2aa6d56 - Restore Python install behavior from before D128230.

Stella Laurenzo llvmlistbot at llvm.org
Sat Jul 9 19:23:11 PDT 2022


Author: Stella Laurenzo
Date: 2022-07-09T19:22:51-07:00
New Revision: 2aa6d56dce293e93240a10ea47222b2ca7d3b3e2

URL: https://github.com/llvm/llvm-project/commit/2aa6d56dce293e93240a10ea47222b2ca7d3b3e2
DIFF: https://github.com/llvm/llvm-project/commit/2aa6d56dce293e93240a10ea47222b2ca7d3b3e2.diff

LOG: Restore Python install behavior from before D128230.

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

Added: 
    

Modified: 
    mlir/cmake/modules/AddMLIRPython.cmake

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 4d05aca5caf86..706413776b9e5 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -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()
 


        


More information about the Mlir-commits mailing list