Xcode projects generated by CMake cannot build documentation
Xcode 14 introduced a new documentation compiler that can automatically build the documentation from the code.
However, if Xcode project is generated by CMake, and there is at least one folder in target_include_directories
that has the same name as the framework's PRODUCT_NAME
, and contains a public header, then the documentation compiler fails as it sees duplicate definitions of classes - one in the public header of the built framework, and another in the original folder.
This does not seem to bother the hand-crafted Xcode project with the same files and build settings.
I've attached a minimal reproducible sample: test.zip. You can reproduce the issue by:
- unzipping the provided file
- create an empty folder and navigate to it
- issue
cmake -GXcode -DCMAKE_SYSTEM_NAME=iOS /path/to/unzipped/folder
- open the generated Xcode project and select
test
scheme - Select
Product->Build Documentation
(or press ctrl+cmd+shift+D)
The documentation should be built, instead, the documentation compiler fails with the error duplicate interface definition for class 'MyTest'
.
Removing target_include_directories
from the provided CMakeLists.txt
seems to resolve the issue, but we cannot do so in production.
I'm using CMake v3.25.2 on M1 Mac.