Xcode cmakeforcelinker breaks build

Not clear where the best place to put some feedback regarding a defect in the Xcode generator.
I have a set of C (not C++) projects. Not surprising I have only C files (*.c) in the project. CMake automatically places a cmakeforcelinker cpp file into the project. I don’t need it or want it. Further, since my code does a bunch of version checking, it automatically breaks the build since there is not meant to be any cpp files in the project. I have not found a way to “find” this file during CMake processing. It is also exceptionally confusing as to why it is being injected in the first place.

CMake, by itself, does not do a such thing!
This injection, probably, comes from some third-party used in your project.

As a side note, Apple tooling requires, at least, one file to generate a shared library. This explains why this injection occurred…

Sorry for the confusion. CMake in source file Source/cmGlobalXCodeGenerator.cxx, lines1684-1695 is responsible for the forced injection of the file I mentioned. The comments indicate it was done to force XCode (at some point, not sure if it would still be relevant) to choose the “right” language. However, since it is based on the linker language, there is additional work needed to validate for C/C++ if the project is intended for only one of the two languages (which is the code that is missing).

My mistake, I did a too quick analysis.

Indeed, specifically for Xcode generator, a source is injected if CMake detect that the target does not include any source matching the link language (by the way, I have no idea why there is a specific treatment just for Xcode generator).

FYI, The link language is computed based on language information from the dependencies of the target. So it seems your project has dependencies over c++ libraries…