Xcode 14: can't find libc.h when building via Make

Building C code for MacOSX. Have a file that references libc.h.

Xcode 13 (with command line tools installed): built fine from Xcode or Make

Xcode 14 (with command line tools installed): builds fine from Xcode. Fails to build from make with error that libc.h cannot be found.

libc.h exists in /Applications/Xcode.app/Contents//Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libc.h but I don’t know how to make sure that CMake with the default generator can find this.

Xcode 14.2
CMake 3.24.2

I think it might be some sort of caching issue.

  • Updated to 3.25.2
  • Ran cmake . in the build directory to regenerate everything.

Got a warning:

CMake Warning at /Applications/CMake.app/Contents/share/cmake-3.25/Modules/Platform/Darwin-Initialize.cmake:303 (message):
Ignoring CMAKE_OSX_SYSROOT value:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk

because the directory does not exist.
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.25/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
CMakeLists.txt:3 (project)

And the CMakeTestCCompiler.cmake failed.

Did a fresh build in a fresh directory and it worked.

I had assumed running “cmake .” in the build directory would reconfigure the entire project, but it seems not.

When the compiler changes, it is recommended to start fresh if anything goes wrong (CMake already does this if the compiler path is detected to have changed). This includes updating Xcode as paths found and cached may need to be rediscovered as the SDK details that get cached can change over time (as you found out).

It does, but knowing what cache values are stale is a hard problem.