cmake suddenly doesn't work with updated Xcode

Viewed 502

I am desperate to solve this problem. I have used cmake (3.18.2) and Xcode for years, but it suddenly has stopped working. Have make the following simple setup:

I made a main.cpp file :

#include <iostream>

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

And the following CMakeLists.txt file:

cmake_minimum_required(VERSION 3.14)
project(untitled)

add_executable(untitled main.cpp)

I make a build file and in it I run:

$ 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".

The cmake being used is from anaconda but this also happens with the homebrew cmake. Both are up to date.

I have installed the latest Xcode and commandline tools (v13.0) because this started with not being able to build an Xcode project, but this seems that this might be independent of Xcode. I have tried resetting the Xcode paths with xcode-select --reset, xcode-select -s /Applications/Xcode.app/Contents/Developer/, xcode-select -s /Library/Developer/CommandLineTools etc. Non of this has helped. I've set the command line tools in Xcode preference->locations.

1 Answers

This is a result of Anaconda resetting environmental variables so that their own build tools are used and not the ones in Xcode Command Line Tools. These where compatible with building a an Xcode project with the cmake provided by Anaconda, but this is no longer the case. You cannot even make a cmake from another source work because Anaconda will force it to use anaconda's tools as well. It is difficult to reset all the necessary environmental variables or make Anaconda compatible with macOS 10.9 SDK or above (see link ) in a more permanent way. Perhaps the interference with the system can be avoided using Conda environments somehow. For me, anaconda interfering with you building your own programs defeats its purpose.

Related