[llvm] [mlir] [CMake][TableGen] Make TableGen CMake functions compatible with CMP0116 (PR #72333)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 06:37:08 PST 2023


================
@@ -19,19 +19,34 @@ function(tablegen project ofn)
 
   # Use depfile instead of globbing arbitrary *.td(s) for Ninja.
   if(CMAKE_GENERATOR MATCHES "Ninja")
-    # Make output path relative to build.ninja, assuming located on
-    # ${CMAKE_BINARY_DIR}.
     # CMake emits build targets as relative paths but Ninja doesn't identify
-    # absolute path (in *.d) as relative path (in build.ninja)
-    # Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
-    file(RELATIVE_PATH ofn_rel
-      ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
-    set(additional_cmdline
-      -o ${ofn_rel}
-      -d ${ofn_rel}.d
-      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-      DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
-      )
+    # absolute path (in *.d) as relative path (in build.ninja).  If CMP0116 is
+    # NEW, CMake handles this discrepancy for us -- otherwise, we have to work
+    # around it ourselves.
+    if(POLICY CMP0116)
----------------
chapuni wrote:

Could we omit it since we use CMake>=3.20?

https://github.com/llvm/llvm-project/pull/72333


More information about the llvm-commits mailing list