From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: openKylinBot <openKylinBot@openkylin.top>
Date: Oct, 19 2026 19:26:49 +0000
Subject: [PATCH] Fix FTBFS with CMake 4.x: stop requesting the removed CMP0059 OLD behavior

Description: Do not request the removed CMP0059 OLD behavior on CMake >= 4.0
 The OLD behavior of policy CMP0059 was removed in CMake 4.0, so calling
 "cmake_policy(SET CMP0059 OLD)" is a hard error there and aborts the
 configuration step of the build:
 .
   CMake Error at cmake/modules/SetKDbCMakePolicies.cmake:12 (cmake_policy):
     Policy CMP0059 may not be set to OLD behavior because this version of
     CMake no longer supports it.
 .
 The OLD behavior is now requested only when running CMake < 4.0, so the
 behavior on older CMake versions stays exactly as before; on CMake >= 4.0
 the NEW behavior is selected explicitly, which is the only behavior still
 available there.
 .
 The build failure is caused by the CMake version present in the build
 environment, not by the architecture: arm64 and riscv64 builders use
 cmake 4.2.3 and fail, while amd64/loong64 still build with cmake 3.28.3.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Forwarded: not-needed
Last-Update: 2026-10-19

--- kdb-3.2.0.orig/cmake/modules/SetKDbCMakePolicies.cmake
+++ kdb-3.2.0/cmake/modules/SetKDbCMakePolicies.cmake
@@ -9,7 +9,13 @@ cmake_policy(SET CMP0053 NEW) # TODO rem
                               # "Simplify variable reference and escape sequence evaluation"
 
 if(POLICY CMP0059) # Don’t treat DEFINITIONS as a built-in directory property.
-    cmake_policy(SET CMP0059 OLD)
+    if(CMAKE_VERSION VERSION_LESS 4.0)
+        # The OLD behavior of CMP0059 is only supported by CMake < 4.0; newer
+        # CMake versions removed it and require the NEW behavior instead.
+        cmake_policy(SET CMP0059 OLD)
+    else()
+        cmake_policy(SET CMP0059 NEW)
+    endif()
 endif()
 if(POLICY CMP0063) # Honor visibility properties for all target types (since cmake 3.3)
     cmake_policy(SET CMP0063 NEW)
