================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to