File tree Expand file tree Collapse file tree 3 files changed +30
-26
lines changed Expand file tree Collapse file tree 3 files changed +30
-26
lines changed Original file line number Diff line number Diff line change 1
1
# CMake policy settings shared between LLVM projects
2
2
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
+
3
9
# MSVC debug information format flags are selected via
4
10
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
5
11
# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE.
Original file line number Diff line number Diff line change @@ -21,21 +21,20 @@ function(tablegen project ofn)
21
21
message (FATAL_ERROR "${project} _TABLEGEN_EXE not set" )
22
22
endif ()
23
23
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}.
31
28
# 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} )
35
33
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
39
38
)
40
39
set (local_tds )
41
40
set (global_tds )
Original file line number Diff line number Diff line change @@ -42,21 +42,20 @@ function(_pdll_tablegen project ofn)
42
42
message (FATAL_ERROR "${project} _TABLEGEN_EXE not set" )
43
43
endif ()
44
44
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}.
52
49
# 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} )
56
54
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
60
59
)
61
60
set (local_tds )
62
61
set (global_tds )
You can’t perform that action at this time.
0 commit comments