我使用的是 macOS Monterey 12.3。 当我尝试在 CLion 上加载 CMAKE 文件时。我收到此错误,它表示找不到 MacOSX12.1.SDK。但我当前的版本是12.3。我不知道为什么它会变成 12.1 版本而不是 12.3。
CMake Warning at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Darwin-Initialize.cmake:303 (message):
Ignoring CMAKE_OSX_SYSROOT value:
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk"
because the directory does not exist.
还有这样的警告:
CMake Error in Build/Debug/_deps/glew-src/CMakeLists.txt:
Imported target "OpenGL::GLU" includes non-existent path
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
同时,当我尝试编译我的程序时,我收到多个 clang 错误,如下所示
include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Werror,-Wstdlibcxx-not-found]
对于这部分,我尝试了首先删除当前版本的 commandLineTools 并执行
Xcode-select --install
修复它的方法。但在我这样做之后,这些错误仍然存在:(
我不确定我对我的 Mac 做了什么,它突然变成这样了。
Cmake 缓存了一个旧的 sdk 路径,该路径在升级 Xcode 后不再存在。
您需要清除cmake缓存,最简单的方法就是删除构建目录。