================
@@ -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()
----------------
JDevlieghere wrote:

I don't think we should try to compute `CMAKE_OSX_SYSROOT` ourselves. If we 
need an `-isysroot` for the `mig` invocation, it's fine to compute it, but we 
shouldn't reuse `CMAKE_OSX_SYSROOT` for that. The 
[documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html)
 before the `project()` call.

Here's what I think we should do instead:

```
if (CMAKE_OSX_SYSROOT)
  set(MIG_SYSROOT ${CMAKE_OSX_SYSROOT})
else() 
  # Set the sysroot based on the output of `xcrun --show-sdk-path`
endif()
```

And then the mig invocation should use `${MIG_SYSROOT}` instead of 
`${CMAKE_OSX_SYSROOT}`.

`xcrun` is the usual way to get the SDK path and by not specifying the SDK, it 
will honor the usual ways of changing the SDK (which matters to us internally). 

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