Skip to content

Commit 4e7c209

Browse files
committed
[lldb][cmake] Error out when building debugserver with CMake 4
CMake 4 no longer sets the `CMAKE_OSX_SYSROOT` variable by default. If you've updated to CMake 4 on macOS (e.g. with brew) and try building LLDB with CMake/ninja, this will yield an error when building debugserver that clang is unable to run since it tries to compile files that don't exist. These files are supposed to be generated by the `mig` process. `mig` needs the `CMAKE_OSX_SYSROOT` variable in order to work and without it, it silently fails to generate the files that later on need to be compiled. This commit will fatal error out of config when building debugserver without having set CMAKE_OSX_SYSROOT.
1 parent 76d83e6 commit 4e7c209

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lldb/tools/debugserver/source/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ endif()
154154

155155
add_definitions(-DLLDB_USE_OS_LOG)
156156

157+
if(NOT CMAKE_OSX_SYSROOT)
158+
execute_process(COMMAND xcodebuild -version -sdk macosx Path
159+
OUTPUT_VARIABLE SDKROOT
160+
ERROR_QUIET
161+
OUTPUT_STRIP_TRAILING_WHITESPACE)
162+
163+
if(NOT EXISTS ${SDKROOT})
164+
message(FATAL_ERROR "Unable to obtain macOS SDK root, debugserver cannot be built.")
165+
endif()
166+
167+
message(STATUS "Using macOS SDK root: ${SDKROOT}")
168+
set(CMAKE_OSX_SYSROOT ${SDKROOT})
169+
endif()
170+
157171
if(${CMAKE_OSX_SYSROOT} MATCHES ".Internal.sdk$")
158172
message(STATUS "LLDB debugserver energy support is enabled")
159173
add_definitions(-DLLDB_ENERGY)

0 commit comments

Comments
 (0)