New MacOS and Xcode update incompatible with Cmake?

I’ve been running code smoothly for the last few weeks up until today after my macOS updated to Sonoma 14.2.1 and Xcode to 15.2 overnight. I updated cmake using homebrew to the latest version: 3.28.1, but now I’m getting strange errors:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$MU3EPREFIX/software/install $MU3EPREFIX/software/mu3eAna

CMake Warning at /usr/local/Cellar/cmake/3.28.1/share/cmake/Modules/Platform/Darwin-Initialize.cmake:308 (message):
Ignoring CMAKE_OSX_SYSROOT value:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk

because the directory does not exist.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.28.1/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake:34 (include)
CMakeLists.txt:3 (project)

– The C compiler identification is AppleClang 15.0.0.15000100
– The CXX compiler identification is AppleClang 15.0.0.15000100
– Detecting C compiler ABI info
– Detecting C compiler ABI info - failed
– Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
– Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - broken
CMake Error at /usr/local/Cellar/cmake/3.28.1/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

"/Library/Developer/CommandLineTools/usr/bin/cc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: '/Users/alexgavin/Project/software/build/mu3eAna/CMakeFiles/CMakeScratch/TryCompile-Hnhd8Y'

Run Build Command(s): /usr/local/Cellar/cmake/3.28.1/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_a68cb/fast
/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_a68cb.dir/build.make CMakeFiles/cmTC_a68cb.dir/build
Building C object CMakeFiles/cmTC_a68cb.dir/testCCompiler.c.o
/Library/Developer/CommandLineTools/usr/bin/cc    -MD -MT CMakeFiles/cmTC_a68cb.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_a68cb.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_a68cb.dir/testCCompiler.c.o -c /Users/alexgavin/Project/software/build/mu3eAna/CMakeFiles/CMakeScratch/TryCompile-Hnhd8Y/testCCompiler.c
Linking C executable cmTC_a68cb
/usr/local/Cellar/cmake/3.28.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a68cb.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a68cb.dir/testCCompiler.c.o -o cmTC_a68cb 
ld: library 'System' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_a68cb] Error 1
make: *** [cmTC_a68cb/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)

– Configuring incomplete, errors occurred!

Anyone got any ideas?

Delete your build directory and start with a fresh build.

1 Like

Hi, thanks for your suggestion. I’ve tried uninstalling and reinstalling but to no avail. I’m using homebrew so I’m not sure if that’s the problem?

Please try the following minimal project, which should at least confirm whether you have a working toolchain and CMake installation:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.28)
project(minimal)

This works for me with essentially the same versions of things as you.

I am using too Sonoma (14.2.1) and cmake 3.28.1. I use cmake installed with the package downloaded from cmake.org

He means the build directory. This error happens sometimes when I update macos like that too across projects.

Say I previously did

cmake -B build

For some project, then macos/xcode upgrades ad I get that error. In that same directory as before I do

rm -r build

cmake -B build

And all is well.

Hi, thanks for the reply. I’m not too familiar with cmake and only really use it to compile code that uses cmake files (I did not write them). I uninstalled cmake with homebrew and tried to build from scratch and I’ve got up to make install but now it’s requesting a password and administrative privileges so I’m not really sure what’s going on. Do you perhaps know what the equivalent of this fix is for cmake installed with homebrew?

I tried this and got the following output:

cmake CMakeLists.txt

– The C compiler identification is AppleClang 15.0.0.15000100

– The CXX compiler identification is AppleClang 15.0.0.15000100

– Detecting C compiler ABI info

– Detecting C compiler ABI info - done

– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped

– Detecting CXX compile features

– Detecting CXX compile features - done

– Configuring done (23.0s)

– Generating done (0.0s)

– Build files have been written to: /Users/alexgavin/software/cmake/test

Thanks for everyone’s suggestions. After hours searching Google somebody recommended trying the command:

export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

It seemed to fix things (I think the SDK path was wrong?) although I’m getting some deprecation errors, but at least it works!