CMake fails to detect xlC 16 via CMakeCCompilerId.c
Specifically, xlC needs to be wrapped or linked such that the compiler basename is cc
and exists on PATH
so that (I'm assuming) the toolchain detection routines kick in.
The reproduction works like so:
$ cat source/CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(test C)
add_executable(test test.c)
$ which cc
/tmp/tmp.MGA9IsdGVH/cc
$ cmake --version
cmake version 3.22.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ cmake -S source -B build
CMake Error at /path/to/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"/tmp/tmp.MGA9IsdGVH/cc"
is not able to compile a simple test program.
...snip...
Linking C executable cmTC_466c9
/path/to/bin/cmake -E cmake_link_script CMakeFiles/cmTC_466c9.dir/link.txt --verbose=1
/tmp/tmp.MGA9IsdGVH/cc CMakeFiles/cmTC_466c9.dir/testCCompiler.c.o -o cmTC_466c9 /usr/lib /lib
ld: 0711-168 SEVERE ERROR: Input file: /usr/lib
Input files must be regular files.
gmake[1]: *** [CMakeFiles/cmTC_466c9.dir/build.make:99: cmTC_466c9] Error 12
Note that the above works fine with CMake 3.21. Relevant CMake configure logs:
-- The C compiler identification is XL 16.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /tmp/tmp.MGA9IsdGVH/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
A viable workaround using CMake 3.22 is to explicitly set CMAKE_CXX_COMPILER
equal to something with the basename xlC
.