cmake 突然无法与更新的 Xcode 一起使用



我非常想解决这个问题。我已经使用cmake(3.18.2)和Xcode多年,但它突然停止工作。进行以下简单的设置:

我创建了一个main.cpp文件:

#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}

和下面的CMakeLists.txt文件:

cmake_minimum_required(VERSION 3.14)
project(untitled)
add_executable(untitled main.cpp)

我创建了一个构建文件,并在其中运行:

$ cmake ..
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang - broken
CMake Error at /opt/anaconda3/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/gmake cmTC_95f1f/fast && /usr/local/bin/gmake  -f CMakeFiles/cmTC_95f1f.dir/build.make CMakeFiles/cmTC_95f1f.dir/build
gmake[1]: Entering directory '/Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_95f1f.dir/testCCompiler.c.o
/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang   -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/anaconda3/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -o CMakeFiles/cmTC_95f1f.dir/testCCompiler.c.o -c /Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_95f1f
/opt/anaconda3/bin/cmake -E cmake_link_script CMakeFiles/cmTC_95f1f.dir/link.txt --verbose=1
/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/anaconda3/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/opt/anaconda3/lib -L/opt/anaconda3/lib  CMakeFiles/cmTC_95f1f.dir/testCCompiler.c.o -o cmTC_95f1f 
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_95f1f.dir/build.make:106: cmTC_95f1f] Error 1
gmake[1]: Leaving directory '/Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_95f1f/fast] Error 2



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

-- Configuring incomplete, errors occurred!
See also "/Users/bmetcalf/Test/build/CMakeFiles/CMakeOutput.log".
See also "/Users/bmetcalf/Test/build/CMakeFiles/CMakeError.log".

使用的cmake来自anaconda,但这也发生在自制cmake中。都是最新的。

我已经安装了最新的Xcode和命令行工具(v13.0),因为这开始无法构建Xcode项目,但这似乎可能是独立的Xcode。我试过用xcode-select --reset,xcode-select -s /Applications/Xcode.app/Contents/Developer/,xcode-select -s /Library/Developer/CommandLineTools等重置Xcode路径。这些都没有帮助。我已经将Xcode中的命令行工具设置为->locations。

这是Anaconda重置环境变量的结果,以便使用他们自己的构建工具,而不是Xcode命令行工具中的工具。这与使用Anaconda提供的cmake构建Xcode项目是兼容的,但现在不再是这种情况了。你甚至不能从其他来源制作cmake,因为Anaconda也会强迫它使用Anaconda的工具。很难以更永久的方式重置所有必要的环境变量或使Anaconda与macOS 10.9 SDK或更高版本(见链接)兼容。也许使用Conda环境可以以某种方式避免对系统的干扰。对我来说,蟒蛇干扰你构建你自己的程序违背了它的目的。

最新更新