From 8907302f88e7e345ce01eabc77462eefaf9a269c Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Mon, 21 Mar 2022 13:43:02 -0400 Subject: [PATCH] [cmake] Handle iOS, watchOS and tvOS when finding compiler-rt on Apple This patch uses CMAKE_OSX_SYSROOT, which should contain the SDK path that we're building against on Apple platforms, to determine which platform we are compiling for and set the compiler-rt suffix accordingly. Differential Revision: https://reviews.llvm.org/D122161 --- cmake/Modules/HandleCompilerRT.cmake | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/HandleCompilerRT.cmake b/cmake/Modules/HandleCompilerRT.cmake index 51409d6f..a55984c 100644 --- a/cmake/Modules/HandleCompilerRT.cmake +++ b/cmake/Modules/HandleCompilerRT.cmake @@ -20,8 +20,26 @@ function(get_component_name name variable) if(NOT name MATCHES "builtins.*") set(component_name "${name}_") endif() - # TODO: Support ios, tvos and watchos as well. - set(component_name "${component_name}osx") + if (CMAKE_OSX_SYSROOT MATCHES ".+MacOSX.+") + set(component_name "${component_name}osx") + + elseif (CMAKE_OSX_SYSROOT MATCHES ".+iPhoneOS.+") + set(component_name "${component_name}ios") + elseif (CMAKE_OSX_SYSROOT MATCHES ".+iPhoneSimulator.+") + set(component_name "${component_name}iossim") + + elseif (CMAKE_OSX_SYSROOT MATCHES ".+AppleTVOS.+") + set(component_name "${component_name}tvos") + elseif (CMAKE_OSX_SYSROOT MATCHES ".+AppleTVSimulator.+") + set(component_name "${component_name}tvossim") + + elseif (CMAKE_OSX_SYSROOT MATCHES ".+WatchOS.+") + set(component_name "${component_name}watchos") + elseif (CMAKE_OSX_SYSROOT MATCHES ".+WatchSimulator.+") + set(component_name "${component_name}watchossim") + else() + message(FATAL_ERROR "Unknown Apple SDK ${CMAKE_OSX_SYSROOT}, we don't know which compiler-rt library suffix to use.") + endif() else() set(component_name "${name}") endif() -- 2.7.4