[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)
Chelsea Cassanova via lldb-commits
lldb-commits at lists.llvm.org
Thu May 1 14:19:32 PDT 2025
================
@@ -154,6 +154,20 @@ endif()
add_definitions(-DLLDB_USE_OS_LOG)
+if(NOT CMAKE_OSX_SYSROOT)
+ execute_process(COMMAND xcodebuild -version -sdk macosx Path
+ OUTPUT_VARIABLE SDKROOT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(NOT EXISTS ${SDKROOT})
+ message(FATAL_ERROR "Unable to obtain macOS SDK root, debugserver cannot be built.")
+ endif()
+
+ message(STATUS "Using macOS SDK root: ${SDKROOT}")
+ set(CMAKE_OSX_SYSROOT ${SDKROOT})
+endif()
----------------
chelcassanova wrote:
> The [documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html) also says that it should be set before the project()
Ah, I wasn't aware of that. In that case then I can update this to use a local variable instead of messing with the CMake variable itself.
Though I do also have a question. If CMake no longer computer this value and we're not computing it ourselves, is this now Clang's responsibility? The CMake 4 release notes note that `Instead, compilers are expected to choose a default macOS SDK on their own` so I guess it is?
Either way, we can get the path we need from `xcrun` as you said.
https://github.com/llvm/llvm-project/pull/138020
More information about the lldb-commits
mailing list