File tree 3 files changed +26
-30
lines changed
3 files changed +26
-30
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
-
9
3
# MSVC debug information format flags are selected via
10
4
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
11
5
# embedding flags in e.g. CMAKE_CXX_FLAGS_RELEASE.
Original file line number Diff line number Diff line change @@ -21,20 +21,21 @@ 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.
25
- if (CMAKE_GENERATOR MATCHES "Ninja" )
26
- # Make output path relative to build.ninja, assuming located on
27
- # ${CMAKE_BINARY_DIR}.
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))
28
31
# CMake emits build targets as relative paths but Ninja doesn't identify
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} )
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.
33
35
set (additional_cmdline
34
- -o ${ofn_rel}
35
- -d ${ofn_rel} .d
36
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
37
- DEPFILE ${CMAKE_CURRENT_BINARY_DIR} /${ofn} .d
36
+ -o ${ofn}
37
+ -d ${ofn} .d
38
+ DEPFILE ${ofn} .d
38
39
)
39
40
set (local_tds)
40
41
set (global_tds)
Original file line number Diff line number Diff line change @@ -42,20 +42,21 @@ 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.
46
- if (CMAKE_GENERATOR MATCHES "Ninja" )
47
- # Make output path relative to build.ninja, assuming located on
48
- # ${CMAKE_BINARY_DIR}.
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))
49
52
# CMake emits build targets as relative paths but Ninja doesn't identify
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} )
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.
54
56
set (additional_cmdline
55
- -o ${ofn_rel}
56
- -d ${ofn_rel} .d
57
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
58
- DEPFILE ${CMAKE_CURRENT_BINARY_DIR} /${ofn} .d
57
+ -o ${ofn}
58
+ -d ${ofn} .d
59
+ DEPFILE ${ofn} .d
59
60
)
60
61
set (local_tds)
61
62
set (global_tds)
You can’t perform that action at this time.
0 commit comments