xcode generator: Detecting C compiler ABI info fails on firmlink
The capability checks, which are run during the project() call, are failing: -- Detecting C compiler ABI info - failed -- Detecting CXX compiler ABI info - failed
This only happens if
- on macos, using XCode generator
- the build directory is a symbolic firmlink (concept introduced in macos Catalina?) I use these links so that short paths directly under the root directory can be used, despite the root disk being mounted read-only (default for recent macos). That concept has been introduced by apple specifically to replace "real" custom folders under root and are neither soft nor hard links.
Reproduction
I attached a simple example CMake project test_void_p_size.tar.gz. For reproduction, one has to create a symbolic firmlink /w/ which links to /Users/anyUserName/w/. Here is a blog post on how to do that: https://derflounder.wordpress.com/2020/01/18/creating-root-level-directories-and-symbolic-links-on-macos-catalina/
mkdir /w/dev && mkdir /w/bld
put the exampe in /w/dev/test_void_p_size
run cmake:
cmake -G Xcode -S /w/dev/test_void_p_size -B /w/bld/test_void_p_size
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - works
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - works
-- Detecting CXX compile features
-- Detecting CXX compile features - done
sizeof p:
-- Configuring done
-- Generating done
-- Build files have been written to: /w/bld/test_void_p_size
Note the failed Detections and as one of the consequences, that CMAKE_SIZEOF_VOID_P is not set. I first thought it is because of a missing preceding project() directive (https://stackoverflow.com/questions/43379311/why-does-project-affect-cmakes-opinion-on-cmake-sizeof-void-p#43380019) But the project call is evaluated before, as one can see from the "Detecting ..." output.
The same error occurs if I use cmake-gui and paste the paths in -S / -B into the text fields for source and target directory.
The error does not occur if I use /Users/anyUsername/w/... instead of /w/... for -S and -B or in cmake-gui
Note: I also tried Ninja which works fine:
cmake -G Ninja -S /w/dev/test_void_p_size -B /w/bld/test_void_p_size
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
sizeof p: 8
-- Configuring done
-- Generating done
-- Build files have been written to: /w/bld/test_void_p_size
Looking at CMakeError.log shows that with XCode generator the parent path of the firmlink target
/Users/anyUserName/
gets somehow mixed into the compiler paths to the files that cmake uses for its trycompile:
CompileC /w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/Objects-normal/x86_64/CMakeCCompilerABI.o /Users/anyUserName/Applications/CMake.app/Contents/share/cmake-3.20/Modules/CMakeCCompilerABI.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'cmTC_a6028' from project 'CMAKE_TRY_COMPILE')
cd /Users/anyUserName/w/bld/test_void_p_size/CMakeFiles/CMakeTmp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target x86_64-apple-macos10.15 -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCMAKE_INTDIR\=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/w/bld/test_void_p_size/CMakeFiles/CMakeTmp/Debug/include -I/w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/DerivedSources-normal/x86_64 -I/w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/DerivedSources/x86_64 -I/w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/DerivedSources -F/w/bld/test_void_p_size/CMakeFiles/CMakeTmp/Debug -v -Wl,-v -MMD -MT dependencies -MF /w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/Objects-normal/x86_64/CMakeCCompilerABI.d --serialize-diagnostics /w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/Objects-normal/x86_64/CMakeCCompilerABI.dia -c /Users/anyUserName/Applications/CMake.app/Contents/share/cmake-3.20/Modules/CMakeCCompilerABI.c -o /w/bld/test_void_p_size/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_a6028.build/Objects-normal/x86_64/CMakeCCompilerABI.o
error: Build input file cannot be found: '/Users/anyUserName/Applications/CMake.app/Contents/share/cmake-3.20/Modules/CMakeCCompilerABI.c' (in target 'cmTC_a6028' from project 'CMAKE_TRY_COMPILE')