For now, the default build configuration in the XCode scheme is hardcoded in cmXCodeScheme.cxx. For example, the build configuration for launch action(the “RUN” command in XCode) is “Debug”.
Sometimes, it’s not what the users wanted. For the project that I’m working on, I want the default build configuration for “RUN” is “RelWithDebInfo”. Since our project is a huge one, sometimes it took a long time for me to build then realized that I did not choose the right build configuration.
I think we can add a new XCODE_SCHEME_DEFAULT_RUN_CONFIG property for users to set the default build configuration to what they want. I have created a branch to do some tests and it’s working well for me. If this is a meaningful addition to CMake, I would be more than happy to submit a merge request.
Hi, sorry for not following this. After I post this, our team made a decision and switched to another build system. But I have a working draft. The code is actually very simple.
I added a new XCODE_SCHEME_DEFAULT_RUN_CONFIG and in Source/cmXCodeScheme.cxx, instead of WriteLaunchAction(xout, FindConfiguration("Debug"), container); I use:
Rather than adding a new property or variable, I do think it would be better to use the existing CMAKE_DEFAULT_BUILD_TYPE variable for this. If that variable isn’t set, we could use the first config listed in CMAKE_CONFIGURATION_TYPES as a fallback. I think that would still give us the same behavior as now if CMAKE_DEFAULT_BUILD_TYPE isn’t set and CMAKE_CONFIGURATION_TYPES is left at its default value. We should avoid adding a new Xcode-specific variable when a more general, suitable variable already exists.