================ @@ -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) ---------------- petrhosek wrote:
This doesn't distinguish Android which uses the `aarch64-linux-android` (or `aarch64-unknown-linux-android`) triple for which the system name should be `Android`. https://github.com/llvm/llvm-project/pull/203504 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
