From e14502834fe6a9c6c9a439401ac3d2c8fd979267 Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Sun, 8 Jun 2025 00:36:38 -0700
Subject: [PATCH] CMakeLists.txt: Improve checking for CFLAGS

The previous log wasn't clear:
-- Performing Test found
-- Performing Test found - Success
-- Performing Test found
-- Performing Test found - Success
-- Performing Test found
-- Performing Test found - Failed

Use a new var compiler-supports${flag} will make it more clear:
-- Performing Test compiler-supports-fno-strict-overflow
-- Performing Test compiler-supports-fno-strict-overflow - Success
-- Performing Test compiler-supports-fno-delete-null-pointer-checks
-- Performing Test compiler-supports-fno-delete-null-pointer-checks - Success
-- Performing Test compiler-supports-fhardened
-- Performing Test compiler-supports-fhardened - Failed

Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/commit/e14502834fe6a9c6c9a439401ac3d2c8fd979267]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 CMakeLists.txt | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08e3e5274..f275c396b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -416,11 +416,10 @@ endif()
 
 # try to ensure some compiler sanity and hardening options where supported
 foreach (flag -fno-strict-overflow -fno-delete-null-pointer-checks -fhardened)
-	check_c_compiler_flag(${flag} found)
-	if (found)
+	check_c_compiler_flag(${flag} compiler-supports${flag})
+	if (compiler-supports${flag})
 		add_compile_options(${flag})
 	endif()
-	unset(found)
 endforeach()
 
 # generated sources
