diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake @@ -91,15 +91,22 @@ endif() if(APPLE) - # On Darwin if /usr/include doesn't exist, the user probably has Xcode but not - # the command line tools. If this is the case, we need to find the OS X - # sysroot to pass to clang. - if(NOT EXISTS /usr/include) - execute_process(COMMAND xcodebuild -version -sdk macosx Path + # On Darwin if /usr/include/c++ doesn't exist, the user probably has Xcode but + # not the command line tools (or is using macOS 10.14 or newer). If this is + # the case, we need to find the OS X sysroot to pass to clang. + if(NOT EXISTS /usr/include/c++) + execute_process(COMMAND xcrun -sdk macosx --show-sdk-path OUTPUT_VARIABLE OSX_SYSROOT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - set(OSX_SYSROOT_FLAG "-isysroot${OSX_SYSROOT}") + if (NOT OSX_SYSROOT OR NOT EXISTS ${OSX_SYSROOT}) + message(WARNING "Detected OSX_SYSROOT ${OSX_SYSROOT} does not exist") + else() + message(STATUS "Found OSX_SYSROOT: ${OSX_SYSROOT}") + set(OSX_SYSROOT_FLAG "-isysroot${OSX_SYSROOT}") + endif() + else() + set(OSX_SYSROOT_FLAG "") endif() option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)