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
While trying to compile on macOS 15.5 using CMake 4.1.0-rc3, I encountered the following error:
After some research, I found that CMake >= 4.0 now sets the
CMAKE_OSX_SYSROOTvariable 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: