Skip to content

Commit fa65a22

Browse files
Revert "[CMake] Do not set CMP0116 explicitly to old (llvm#90385)"
This reverts commit ab405fb. This caused quite a few buildbot failures that need further investigation.
1 parent 12d1cb1 commit fa65a22

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

cmake/Modules/CMakePolicy.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CMake policy settings shared between LLVM projects
22

3+
# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
4+
# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
5+
if(POLICY CMP0116)
6+
cmake_policy(SET CMP0116 OLD)
7+
endif()
8+
39
# MSVC debug information format flags are selected via
410
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
511
# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE.

llvm/cmake/modules/TableGen.cmake

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@ function(tablegen project ofn)
2121
message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
2222
endif()
2323

24-
# Use depfile instead of globbing arbitrary *.td(s) for Ninja. We force
25-
# CMake versions older than v3.30 on Windows to use the fallback behavior
26-
# due to a depfile parsing bug on Windows paths in versions prior to 3.30.
27-
# https://gitlab.kitware.com/cmake/cmake/-/issues/25943
28-
cmake_policy(GET CMP0116 cmp0116_state)
29-
if(CMAKE_GENERATOR MATCHES "Ninja" AND cmp0116_state STREQUAL NEW
30-
AND NOT (CMAKE_HOST_WIN32 AND CMAKE_VERSION VERSION_LESS 3.30))
24+
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
25+
if(CMAKE_GENERATOR MATCHES "Ninja")
26+
# Make output path relative to build.ninja, assuming located on
27+
# ${CMAKE_BINARY_DIR}.
3128
# CMake emits build targets as relative paths but Ninja doesn't identify
32-
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
33-
# CMake handles this discrepancy for us, otherwise we use the fallback
34-
# logic.
29+
# absolute path (in *.d) as relative path (in build.ninja)
30+
# Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
31+
file(RELATIVE_PATH ofn_rel
32+
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
3533
set(additional_cmdline
36-
-o ${ofn}
37-
-d ${ofn}.d
38-
DEPFILE ${ofn}.d
34+
-o ${ofn_rel}
35+
-d ${ofn_rel}.d
36+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
37+
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
3938
)
4039
set(local_tds)
4140
set(global_tds)

mlir/cmake/modules/AddMLIR.cmake

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,20 @@ function(_pdll_tablegen project ofn)
4242
message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
4343
endif()
4444

45-
# Use depfile instead of globbing arbitrary *.td(s) for Ninja. We force
46-
# CMake versions older than v3.30 on Windows to use the fallback behavior
47-
# due to a depfile parsing bug on Windows paths in versions prior to 3.30.
48-
# https://gitlab.kitware.com/cmake/cmake/-/issues/25943
49-
cmake_policy(GET CMP0116 cmp0116_state)
50-
if(CMAKE_GENERATOR MATCHES "Ninja" AND cmp0116_state STREQUAL NEW
51-
AND NOT (CMAKE_HOST_WIN32 AND CMAKE_VERSION VERSION_LESS 3.30))
45+
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
46+
if(CMAKE_GENERATOR MATCHES "Ninja")
47+
# Make output path relative to build.ninja, assuming located on
48+
# ${CMAKE_BINARY_DIR}.
5249
# CMake emits build targets as relative paths but Ninja doesn't identify
53-
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
54-
# CMake handles this discrepancy for us. Otherwise, we use the fallback
55-
# logic.
50+
# absolute path (in *.d) as relative path (in build.ninja)
51+
# Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
52+
file(RELATIVE_PATH ofn_rel
53+
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
5654
set(additional_cmdline
57-
-o ${ofn}
58-
-d ${ofn}.d
59-
DEPFILE ${ofn}.d
55+
-o ${ofn_rel}
56+
-d ${ofn_rel}.d
57+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
58+
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
6059
)
6160
set(local_tds)
6261
set(global_tds)

0 commit comments

Comments
 (0)