Skip to content

OSX build fails with cmake >= 4.0 #60

@agfline

Description

@agfline

While trying to compile on macOS 15.5 using CMake 4.1.0-rc3, I encountered the following error:

$ cmake  -S .  -B build                            
-- The C compiler identification is AppleClang 17.0.0.17000013
-- The CXX compiler identification is AppleClang 17.0.0.17000013
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at cmake/CMakeOptions.cmake:54 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:20 (include)


-- Configuring incomplete, errors occurred!

After some research, I found that CMake >= 4.0 now sets the CMAKE_OSX_SYSROOT variable to an empty string by default (https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html).

A simple workaround is to specify the sysroot explicitly:

cmake  -S .  -B build -DCMAKE_OSX_SYSROOT=macosx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions