[SOLVED] CMake not finding proper MacOS sdk

Completed

When opening the project I got this error on the CMake tab:

"/Users/<user>/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/202.7660.37/CLion.app/Contents/bin/cmake/mac/bin/cmake" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/<user>/CLionProjects/ppgp2
CMake Warning at /Users/<user>/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/202.7660.37/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Modules/Platform/Darwin-Initialize.cmake:286 (message):
Ignoring CMAKE_OSX_SYSROOT value:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

because the directory does not exist.

After inspecting a bit, I found that is in fact correct since the directories within Xcode SDK are called now 'MacOSX.sdk' and 'MacOS11.sdk' with the latter being really just a shortcut to the former. Just to clarify, I got this error BEFORE upgrading to MacOS11 and still got it after doing so. Proof:

 

My fix for this error (probably not the proper way of doing it but the one I could come up with) is going into the Darwin-Initialize.cmake file which throws the error and forcing CMAKE_OSX_SYSROOT to be the correct path: (I only added the second 'set' line, the rest was there before)

# Transform CMAKE_OSX_SYSROOT to absolute path
set(_CMAKE_OSX_SYSROOT_PATH "")
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
if(CMAKE_OSX_SYSROOT)

Posting it here in case anyone else has this issue or someone sees something wrong with my fast fix. All feedback is appreciated.

 

1 comment
Comment actions Permalink

Actually, deleting `cmake-build-debug` subfolder and calling Tools | CMake | Reset Cache and Reload project should help.

2

Please sign in to leave a comment.