[clang] [HLSL] Fix improper parsing of IN_LIST within if condition (PR #199276)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 22 13:18:07 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Joshua Batista (bob80905)
<details>
<summary>Changes</summary>
Cmake does not properly parse IN_LIST within the if condition, and treats it as a token.
This is not desired behavior.
The CMP0057 policy supports the new [if() IN_LIST ](https://cmake.org/cmake/help/latest/command/if.html#command:if) operator.
Enable this policy and resolve the build error.
Assisted by: Github Copilot
---
Full diff: https://github.com/llvm/llvm-project/pull/199276.diff
1 Files Affected:
- (modified) clang/cmake/caches/HLSL.cmake (+4)
``````````diff
diff --git a/clang/cmake/caches/HLSL.cmake b/clang/cmake/caches/HLSL.cmake
index 66e99a29454f0..40e92fd37382b 100644
--- a/clang/cmake/caches/HLSL.cmake
+++ b/clang/cmake/caches/HLSL.cmake
@@ -21,6 +21,10 @@ endif()
# (docs/offload-distribution.md) for setup, prerequisites, and run
# instructions.
if (HLSL_ENABLE_OFFLOAD_DISTRIBUTION)
+ # Cache scripts run before the project's cmake_minimum_required takes
+ # effect, so CMP0057 still defaults to OLD here and IN_LIST would be
+ # parsed as a literal token. Opt in explicitly so the check below works.
+ cmake_policy(SET CMP0057 NEW)
if (NOT "OffloadTest" IN_LIST LLVM_EXTERNAL_PROJECTS)
message(FATAL_ERROR
"HLSL_ENABLE_OFFLOAD_DISTRIBUTION requires OffloadTest to be enabled "
``````````
</details>
https://github.com/llvm/llvm-project/pull/199276
More information about the cfe-commits
mailing list