CMake: Explicitly set CMAKE_OSX_SYSROOT to macosx for macOS host builds

The implicit default CMAKE_OSX_SYSROOT was a workaround in CMake for
macOS ~10.8. As of CMake 4.x, CMake expects macOS host compilers to have
their own default sysroot detection logic. However, upstream llvm does
not actually do this, only Apple Clang does. To keep supporting homebrew
clang and manually compiled clang from llvm/llvm-project, we need to
set the sysroot explicitly.

The behavior difference and lack of default detection logic in the clang
driver is tracked at https://gitlab.kitware.com/cmake/cmake/-/issues/26863
This commit is contained in:
Andrew Kaster 2025-04-21 14:57:06 -06:00 committed by Tim Flynn
parent 981e465a04
commit e1369aa7d6
Notes: github-actions[bot] 2025-04-22 21:32:16 +00:00
5 changed files with 10 additions and 1 deletions

View file

@ -15,6 +15,10 @@ if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg.cmake$")
set(CMAKE_PROJECT_ladybird_INCLUDE_BEFORE "Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake")
endif()
if (APPLE AND NOT CMAKE_OSX_SYSROOT)
set(CMAKE_OSX_SYSROOT macosx)
endif()
project(ladybird
VERSION 0.1.0
LANGUAGES C CXX

View file

@ -2,5 +2,6 @@ set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_OSX_ARCHITECTURES arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_OSX_SYSROOT macosx)
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)

View file

@ -2,5 +2,6 @@ set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_OSX_ARCHITECTURES x86_64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_OSX_SYSROOT macosx)
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)

View file

@ -60,7 +60,6 @@ cmake -GNinja --preset=Distribution -B Build/tools \
-DCMAKE_INSTALL_PREFIX=Build/tool-install \
-DCMAKE_C_COMPILER=$BEST_CLANG_CANDIDATE \
-DCMAKE_CXX_COMPILER="${BEST_CLANG_CANDIDATE/clang/clang++}" \
-DCMAKE_OSX_SYSROOT=macosx \
-Dpackage=LagomTools
ninja -C Build/tools install

View file

@ -1,5 +1,9 @@
cmake_minimum_required (VERSION 3.21)
if (APPLE AND NOT CMAKE_OSX_SYSROOT)
set(CMAKE_OSX_SYSROOT macosx)
endif()
project(
Lagom
VERSION 0.0.0