[runtimes] [CMake] Unify variable names

Avoid repeating CMake checks across runtimes by unifying names of
variables used for results to leverage CMake caching.

Differential Revision: https://reviews.llvm.org/D110005

GitOrigin-RevId: b3df14b6c98702ce50401fd039852787373e4676
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7d6d19..8d583df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -276,7 +276,7 @@
 # Configure compiler. Must happen after setting the target flags.
 include(config-ix)
 
-if (LIBCXXABI_HAS_NOSTDINCXX_FLAG)
+if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
   list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++)
   # cmake 3.14 and above remove system include paths that are explicitly
   # passed on the command line.  We build with -nostdinc++ and explicitly add
@@ -497,7 +497,7 @@
     add_definitions(-DLIBCXXABI_BAREMETAL)
 endif()
 
-if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
+if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
   if (LIBCXXABI_HAS_PTHREAD_LIB)
     add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB)
   endif()
diff --git a/cmake/Modules/HandleLibcxxabiFlags.cmake b/cmake/Modules/HandleLibcxxabiFlags.cmake
index 512e71a..bf5c5fa 100644
--- a/cmake/Modules/HandleLibcxxabiFlags.cmake
+++ b/cmake/Modules/HandleLibcxxabiFlags.cmake
@@ -41,7 +41,7 @@
 
 macro(check_flag_supported flag)
     mangle_name("${flag}" flagname)
-    check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
+    check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
 endmacro()
 
 macro(append_flags DEST)
@@ -62,8 +62,8 @@
 macro(append_flags_if_supported DEST)
   foreach(flag ${ARGN})
     mangle_name("${flag}" flagname)
-    check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
-    append_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
+    check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
+    append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
   endforeach()
 endmacro()
 
@@ -129,8 +129,8 @@
 macro(add_target_flags_if_supported)
   foreach(flag ${ARGN})
     mangle_name("${flag}" flagname)
-    check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
-    add_target_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
+    check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
+    add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
   endforeach()
 endmacro()
 
@@ -156,8 +156,8 @@
 macro(add_flags_if_supported)
   foreach(flag ${ARGN})
       mangle_name("${flag}" flagname)
-      check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
-      add_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
+      check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
+      add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
   endforeach()
 endmacro()
 
@@ -181,8 +181,8 @@
 macro(add_compile_flags_if_supported)
   foreach(flag ${ARGN})
       mangle_name("${flag}" flagname)
-      check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
-      add_compile_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
+      check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
+      add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
   endforeach()
 endmacro()
 
@@ -191,8 +191,8 @@
 macro(add_c_compile_flags_if_supported)
   foreach(flag ${ARGN})
       mangle_name("${flag}" flagname)
-      check_c_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
-      add_compile_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
+      check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG")
+      add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
   endforeach()
 endmacro()
 
@@ -216,8 +216,8 @@
 macro(add_link_flags_if_supported)
   foreach(flag ${ARGN})
     mangle_name("${flag}" flagname)
-    check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
-    add_link_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
+    check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
+    add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
   endforeach()
 endmacro()
 
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index efc572e..079cabf 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -23,17 +23,17 @@
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
 
-check_c_compiler_flag(-nostdlib++ LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG)
-if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG)
+check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
-  check_c_compiler_flag(-nodefaultlibs LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
-  if (LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
+  check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
+  if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
   endif()
 endif()
 
-if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBCXXABI_HAS_C_LIB)
     list(APPEND CMAKE_REQUIRED_LIBRARIES c)
   endif ()
@@ -78,12 +78,12 @@
   check_c_source_compiles("
 #pragma comment(lib, \"c\")
 int main() { return 0; }
-" LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
+" C_SUPPORTS_COMMENT_LIB_PRAGMA)
   cmake_pop_check_state()
 endif()
 
 # Check compiler flags
-check_cxx_compiler_flag(-nostdinc++ LIBCXXABI_HAS_NOSTDINCXX_FLAG)
+check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
 
 # Check libraries
 if(FUCHSIA)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d1c6ad8..2ce8dd8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -116,7 +116,7 @@
 endif ()
 
 # Setup flags.
-if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG)
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
   add_link_flags_if_supported(-nostdlib++)
 else()
   add_link_flags_if_supported(-nodefaultlibs)