[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
This commit is contained in:
Louis Dionne 2022-03-21 13:43:02 -04:00
parent 7f7f4be78a
commit 8907302f88
1 changed files with 20 additions and 2 deletions

View File

@ -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()