-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CMake][TableGen] Make TableGen CMake functions compatible with CMP0116 #72333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,34 @@ 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}) | ||
set(additional_cmdline | ||
-o ${ofn_rel} | ||
-d ${ofn_rel}.d | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d | ||
) | ||
# absolute path (in *.d) as relative path (in build.ninja). If CMP0116 is | ||
# NEW, CMake handles this discrepancy for us -- otherwise, we have to work | ||
# around it ourselves. | ||
if(POLICY CMP0116) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we omit it since we use CMake>=3.20? |
||
cmake_policy(GET CMP0116 cmp0116_state) | ||
else() | ||
set(cmp0116_state OLD) | ||
endif() | ||
if(cmp0116_state STREQUAL NEW) | ||
set(additional_cmdline | ||
-o ${ofn} | ||
-d ${ofn}.d | ||
DEPFILE ${ofn}.d | ||
) | ||
else() | ||
# Make output path relative to build.ninja, assuming located on | ||
# ${CMAKE_BINARY_DIR}. | ||
# 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}) | ||
set(additional_cmdline | ||
-o ${ofn_rel} | ||
-d ${ofn_rel}.d | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d | ||
) | ||
Comment on lines
+38
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we may rely on the new policy and drop old logic. |
||
endif() | ||
set(local_tds) | ||
set(global_tds) | ||
else() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be fair to fall back to
file(GLOB)
ifCMP0116
isOLD
.