Xcode generator doesn't set correct explicitFileType based on LANGUAGE for Objective-C++ files
Hello!
I noticed another issue with the Objective-C++ support and the Xcode generator. It turns out that the Xcode generator doesn't seem to care about the LANGUAGE property on source files.
I have the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(test-objc C CXX OBJCXX)
add_executable(hello hello.cpp)
set_source_files_properties(hello.cpp PROPERTIES LANGUAGE OBJCXX)
This works fine with Ninja and Makefiles but not with Xcode - the file is not built at all.
I traced it down to the explicitFileType
being set to sourcecode
:
3DE340914549401FBA1AD8F4 /* /Users/tobias/Code/objc-xcode/hello.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode; fileEncoding = 4; name = hello.cpp; path = hello.cpp; sourceTree = SOURCE_ROOT; }
I can get around this by setting: XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
on the source file so it's not a breaking bug. But it seems like maybe CMake should handle this case.
I think the problem is here:
https://gitlab.kitware.com/cmake/cmake/blob/v3.16.0-rc4/Source/cmGlobalXCodeGenerator.cxx#L941
This switch statement probably need to check for objective-c and objective-c++.