I have multiple Xcode versions installed on my system using the XcodesApp. Whenever I need to work with a specific Xcode version, I have to switch between them using the xcodes select
command:
xcodes select 14.3.1 # or 15.3, etc.
After selecting the desired Xcode version, I use CMake to generate Ninja build files for my projects. However, having to switch Xcode versions manually every time is quite tedious and prevents me from concurrently building projects that require different Xcode versions.
Is there an official or recommended way to configure CMake to use the appropriate Xcode toolchain (compilers, linkers, etc.) for each project without having to manually switch between Xcode versions? Ideally, I'd like to be able to specify the desired Xcode version when running CMake, and have it automatically use the corresponding toolchain for that version.
I'm aware that one potential solution could be to create separate toolchain files for each Xcode version, specifying the paths to the compilers and other tools. However, I'm wondering if there's a more official or recommended approach from Apple or the CMake community.
Any guidance or suggestions on how to achieve this would be greatly appreciated.