[llvm] build(llvm): set CMP0219 to OLD to prevent backslash interpretation (PR #228949)

Eisuke Kawashima via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 16:13:27 PDT 2026


https://github.com/e-kwsm updated https://github.com/llvm/llvm-project/pull/228949

>From 3fc208c2436b07caf45cc6b65b23dbabbfdaf337 Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima <e.kawaschima+llvm at gmail.com>
Date: Mon, 5 Oct 2026 08:06:01 +0900
Subject: [PATCH] build(llvm): set CMP0219 to OLD to prevent backslash
 interpretation

CMake 4.4 introduced a breaking change of treatment of backslashes.
Set CMP0219 to OLD so that it works with CMake 4.4 and previous
versions.
https://cmake.org/cmake/help/v4.4/policy/CMP0219.html

Also bracket notation is used for readability.

fix #228948
---
 llvm/cmake/modules/HandleLLVMOptions.cmake | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 943418f7ec0da61..6ca6e70812b3016 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -955,9 +955,14 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
 
   # Check if -Wcomment is OK with an // comment ending with '\' if the next
   # line is also a // comment.
+  if(POLICY CMP0219)
+    cmake_policy(SET CMP0219 OLD)
+  endif()
   set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wcomment")
-  CHECK_C_SOURCE_COMPILES("// \\\\\\n//\\nint main(void) {return 0;}"
+  CHECK_C_SOURCE_COMPILES([=[// \\
+//
+int main(void) {return 0;}]=]
                           C_WCOMMENT_ALLOWS_LINE_WRAP)
   set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
   if (NOT C_WCOMMENT_ALLOWS_LINE_WRAP)



More information about the llvm-commits mailing list