xcode: add support for xcconfig files
This draft PR adds support for .xcconfig
files to the Xcode Generator. It could be used the following way:
set(CMAKE_XCODE_XCCONFIG "$<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/bar.xcconfig,>")
add_library(bar
bar.c
# Those xcconfig files are automatically added to the target if not already present
#bar.xcconfig
#${CMAKE_CURRENT_SOURCE_DIR}/bar_debug.xcconfig
#bar_release.xcconfig
)
set_target_properties(bar PROPERTIES
XCODE_XCCONFIG "$<IF:$<CONFIG:Release,RelWithDebInfo>,bar_release.xcconfig,bar_debug.xcconfig>"
)
For a project-level xcconfig file the CMAKE_XCODE_XCCONFIG
variable has to be set. Because any referenced files have to be present in the Xcode project, they are added to the ALL_BUILD
build target.
Target-level xcconfig files are added by the XCODE_XCCONFIG
property. They are added to the target sources if not already present.
Before I start adding documentation and tests I'd like to get the code right. As far as I understand the CMake architecture, extra source files have to be added in the configuration phase. The Xcode project is then created in the generation phase.
I hope I placed the functionality into the right spots. But I'd like to have the code reviewed by developers more knowledgeable and experienced with the CMake architecture. I might have violated some layering/abstraction design decisions.
Thanks, Gregor
CC: @craig.scott
Fixes: #18420 (closed)