[Mlir-commits] [llvm] [mlir] [CMake] Do not set CMP0116 explicitly to old (PR #90385)
Aiden Grossman
llvmlistbot at llvm.org
Mon Oct 28 00:11:25 PDT 2024
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/90385
>From c4d53f34c7d9ad96a4d0b7c58971bc4d596565ab Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sun, 28 Apr 2024 08:34:53 +0000
Subject: [PATCH 1/6] [CMake] Do not set CMP0116 explicitly to old
CMP0116 was originally set to old to get rid of warnings. However, this
behavior is now set to new by default with the minimum CMake version that LLVM
requires so does not produce any warnings, and setting it explicitly to old
does produce a warning in newer CMake versions. Due to these reasons, remove
this check for now.
Splitting off from removing the CMP0114 check just in case something breaks.
This also removes two instances of a workaround related to the old
behavior of CMP0116.
Partially fixes #83727.
---
cmake/Modules/CMakePolicy.cmake | 6 ------
llvm/cmake/modules/TableGen.cmake | 15 +++++----------
mlir/cmake/modules/AddMLIR.cmake | 13 +++++--------
3 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/cmake/Modules/CMakePolicy.cmake b/cmake/Modules/CMakePolicy.cmake
index f19dfd71657171..f6ecc40d8f1279 100644
--- a/cmake/Modules/CMakePolicy.cmake
+++ b/cmake/Modules/CMakePolicy.cmake
@@ -1,11 +1,5 @@
# CMake policy settings shared between LLVM projects
-# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
-# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
-if(POLICY CMP0116)
- cmake_policy(SET CMP0116 OLD)
-endif()
-
# MSVC debug information format flags are selected via
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE.
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index ffcc718b47775f..d2ff1cfa553b39 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -23,18 +23,13 @@ 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})
+ # absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
+ # CMake handles this discrepancy for us.
set(additional_cmdline
- -o ${ofn_rel}
- -d ${ofn_rel}.d
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
+ -o ${ofn}
+ -d ${ofn}.d
+ DEPFILE ${ofn}.d
)
set(local_tds)
set(global_tds)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index a3324705c525ce..bbe5976d7a3e76 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -47,15 +47,12 @@ function(_pdll_tablegen project ofn)
# 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})
+ # absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
+ # CMake handles this discrepancy for us.
set(additional_cmdline
- -o ${ofn_rel}
- -d ${ofn_rel}.d
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
+ -o ${ofn}
+ -d ${ofn}.d
+ DEPFILE ${ofn}.d
)
set(local_tds)
set(global_tds)
>From 38d22397304e175ca6b70b8e6a1b7e2fd25558a6 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sat, 19 Oct 2024 03:53:27 +0000
Subject: [PATCH 2/6] Address feedback
---
llvm/cmake/modules/TableGen.cmake | 6 ++++--
mlir/cmake/modules/AddMLIR.cmake | 8 ++++----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index d2ff1cfa553b39..653fd25358946f 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -22,10 +22,12 @@ function(tablegen project ofn)
endif()
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
- if(CMAKE_GENERATOR MATCHES "Ninja")
+ cmake_policy(GET CMP0116 CMP0116_STATE)
+ if(CMAKE_GENERATOR MATCHES "Ninja" AND CMP0116_STATE STREQUAL NEW)
# CMake emits build targets as relative paths but Ninja doesn't identify
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
- # CMake handles this discrepancy for us.
+ # CMake handles this discrepancy for us, otherwise we use the fallback
+ # logic.
set(additional_cmdline
-o ${ofn}
-d ${ofn}.d
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index bbe5976d7a3e76..ed34d428b32374 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -43,12 +43,12 @@ function(_pdll_tablegen project ofn)
endif()
# 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_policy(GET CMP0116 CMP0116_STATE)
+ if(CMAKE_GENERATOR MATCHES "Ninja" AND CMP0116_STATE STREQUAL NEW)
# CMake emits build targets as relative paths but Ninja doesn't identify
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
- # CMake handles this discrepancy for us.
+ # CMake handles this discrepancy for us. Otherwise, we use the fallback
+ # logic.
set(additional_cmdline
-o ${ofn}
-d ${ofn}.d
>From 3265c198593e90e1d64808ec7bcb4a48a36005e4 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sat, 19 Oct 2024 22:09:05 +0000
Subject: [PATCH 3/6] Address feedback
---
llvm/cmake/modules/TableGen.cmake | 4 ++--
mlir/cmake/modules/AddMLIR.cmake | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 653fd25358946f..56a5dc40839254 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -22,8 +22,8 @@ function(tablegen project ofn)
endif()
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
- cmake_policy(GET CMP0116 CMP0116_STATE)
- if(CMAKE_GENERATOR MATCHES "Ninja" AND CMP0116_STATE STREQUAL NEW)
+ cmake_policy(GET CMP0116 cmp0116_state)
+ if(CMAKE_GENERATOR MATCHES "Ninja" AND cmp0116_state STREQUAL NEW)
# CMake emits build targets as relative paths but Ninja doesn't identify
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
# CMake handles this discrepancy for us, otherwise we use the fallback
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index ed34d428b32374..b39a3e7ee2401b 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -43,8 +43,8 @@ function(_pdll_tablegen project ofn)
endif()
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
- cmake_policy(GET CMP0116 CMP0116_STATE)
- if(CMAKE_GENERATOR MATCHES "Ninja" AND CMP0116_STATE STREQUAL NEW)
+ cmake_policy(GET CMP0116 cmp0116_state)
+ if(CMAKE_GENERATOR MATCHES "Ninja" AND cmp0116_state STREQUAL NEW)
# CMake emits build targets as relative paths but Ninja doesn't identify
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
# CMake handles this discrepancy for us. Otherwise, we use the fallback
>From 7aa41fd90c1d5773c7b75081d151c8f3f96d87db Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 28 Oct 2024 05:51:33 +0000
Subject: [PATCH 4/6] Explicitly set policy to new
---
cmake/Modules/CMakePolicy.cmake | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/cmake/Modules/CMakePolicy.cmake b/cmake/Modules/CMakePolicy.cmake
index f6ecc40d8f1279..257d1b556ecda4 100644
--- a/cmake/Modules/CMakePolicy.cmake
+++ b/cmake/Modules/CMakePolicy.cmake
@@ -1,5 +1,11 @@
# CMake policy settings shared between LLVM projects
+# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
+# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
+if(POLICY CMP0116)
+ cmake_policy(SET CMP0116 NEW)
+endif()
+
# MSVC debug information format flags are selected via
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE.
>From ec66b31b8ab7e3a46d2012a0b1475a13af899cc0 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 28 Oct 2024 07:03:46 +0000
Subject: [PATCH 5/6] bump CI
---
cmake/Modules/CMakePolicy.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmake/Modules/CMakePolicy.cmake b/cmake/Modules/CMakePolicy.cmake
index 257d1b556ecda4..f19dfd71657171 100644
--- a/cmake/Modules/CMakePolicy.cmake
+++ b/cmake/Modules/CMakePolicy.cmake
@@ -3,7 +3,7 @@
# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
if(POLICY CMP0116)
- cmake_policy(SET CMP0116 NEW)
+ cmake_policy(SET CMP0116 OLD)
endif()
# MSVC debug information format flags are selected via
>From e03f42a60b34e9d97eb06c2f95c62dd8c55e464e Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 28 Oct 2024 07:11:03 +0000
Subject: [PATCH 6/6] bump CI
---
cmake/Modules/CMakePolicy.cmake | 6 ------
1 file changed, 6 deletions(-)
diff --git a/cmake/Modules/CMakePolicy.cmake b/cmake/Modules/CMakePolicy.cmake
index f19dfd71657171..f6ecc40d8f1279 100644
--- a/cmake/Modules/CMakePolicy.cmake
+++ b/cmake/Modules/CMakePolicy.cmake
@@ -1,11 +1,5 @@
# CMake policy settings shared between LLVM projects
-# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
-# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
-if(POLICY CMP0116)
- cmake_policy(SET CMP0116 OLD)
-endif()
-
# MSVC debug information format flags are selected via
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE.
More information about the Mlir-commits
mailing list