File tree Expand file tree Collapse file tree 3 files changed +26
-30
lines changed Expand file tree Collapse file tree 3 files changed +26
-30
lines changed Original file line number Diff line number Diff line change 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-
93# MSVC debug information format flags are selected via
104# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT, instead of
115# 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)
2121 message (FATAL_ERROR "${project} _TABLEGEN_EXE not set" )
2222 endif ()
2323
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))
2831 # 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.
3335 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
3839 )
3940 set (local_tds)
4041 set (global_tds)
Original file line number Diff line number Diff line change @@ -42,20 +42,21 @@ 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.
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))
4952 # 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.
5456 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
5960 )
6061 set (local_tds)
6162 set (global_tds)
You can’t perform that action at this time.
0 commit comments