[clang] [llvm] runtimes: Pass CMAKE_SYSTEM_NAME based on target triple (PR #203504)
Tomohiro Kashiwada via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 12 07:21:00 PDT 2026
================
@@ -0,0 +1,82 @@
+#===--------------------------------------------------------------------===//
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for details.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===--------------------------------------------------------------------===//
+
+# Extract the OS component from a target triple and map it to the
+# corresponding CMake system name.
+#
+# Usage:
+# get_triple_cmake_system_name(<triple> <out_var>)
+#
+# Parses the triple (arch-vendor-os[-env]) and sets <out_var> to the
+# CMake-style system name (e.g. "Darwin", "Linux", "Windows").
+# Unrecognized OS values are mapped to "Generic".
+
+function(get_triple_cmake_system_name triple out_var)
+ string(REPLACE "-" ";" _components "${triple}")
+ list(LENGTH _components _len)
+ if(_len LESS 3)
+ set(${out_var} "${CMAKE_HOST_SYSTEM_NAME}" PARENT_SCOPE)
+ return()
+ endif()
+
+ list(GET _components 1 _vendor)
+ list(GET _components 2 _os)
+
+ if("${_os}" MATCHES "^darwin|^macos")
+ set(${out_var} "Darwin" PARENT_SCOPE)
+ elseif("${_os}" MATCHES "^ios")
+ set(${out_var} "iOS" PARENT_SCOPE)
+ elseif("${_os}" MATCHES "^tvos")
+ set(${out_var} "tvOS" PARENT_SCOPE)
+ elseif("${_os}" MATCHES "^watchos")
+ set(${out_var} "watchOS" PARENT_SCOPE)
+ elseif("${_os}" MATCHES "^xros|^visionos")
+ set(${out_var} "visionOS" PARENT_SCOPE)
+ elseif("${_vendor}" STREQUAL "apple")
+ # Catch-all for other Apple triples (e.g. driverkit, bridgeos).
+ set(${out_var} "Darwin" PARENT_SCOPE)
+ elseif("${_os}" MATCHES "^linux")
+ set(${out_var} "Linux" PARENT_SCOPE)
+ elseif("${_os}" MATCHES "^win32|^windows|^mingw")
----------------
kikairoya wrote:
The canonical form of Cygwin, `x86_64-unknown-windows-cygnus`, matches unintendedly here.
https://github.com/llvm/llvm-project/pull/203504
More information about the cfe-commits
mailing list