From d450b92e6faa361dae7f425e285b42b6792691d0 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Tue, 1 Dec 2020 17:22:22 +0000 Subject: Detect system include headers on macOS System header files on macOS are not part of `/usr/include` since Catalina. Instead, multiple locations are possible and depend on the selected SDK. Use `xcrun` to automatically detect the correct path on macOS. --- test/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f850d745..a5418a51 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,6 +18,16 @@ set(NATIVE_CC "${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -I ${CMAKE_SOURCE_DIR}/inclu set(NATIVE_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} -I ${CMAKE_SOURCE_DIR}/include") set(TARGET_TRIPLE "${TARGET_TRIPLE}") +# Extend native compiler invocation on macOS to point to the currently selected systems directory +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + execute_process( + COMMAND xcrun --sdk macosx --show-sdk-path + OUTPUT_VARIABLE MAC_OS_SDK_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(NATIVE_CC "${NATIVE_CC} -isysroot ${MAC_OS_SDK_PATH}") + set(NATIVE_CXX "${NATIVE_CXX} -isysroot ${MAC_OS_SDK_PATH}") +endif() + # FIXME: Do this to avoid changing the template file that # is shared by both build systems. if (ENABLE_POSIX_RUNTIME) -- cgit 1.4.1