================
@@ -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)
----------------
petrhosek wrote:

This would fail to match `x86_64-linux-gnu` since `linux` would be considered a 
vendor. We would need to mandate the canonical triple spelling or normalize the 
triple first.

https://github.com/llvm/llvm-project/pull/203504
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to