Skip to content

Use GENERATOR_IS_MULTI_CONFIG to detect multi-config generators

Various places in Tests and Modules were using CMAKE_CONFIGURATION_TYPES to determine whether or not the current generator is multi-config or not. This is not completely robust, since projects/developers can (and sometimes do) explicitly set CMAKE_CONFIGURATION_TYPES even for single-config generators. Since CMake 3.9, the GENERATOR_IS_MULTI_CONFIG global property is available which definitively provides whether or not the current generator is multi-config, so use that where available instead.

The changes were made by doing a recursive search for CMAKE_CONFIGURATION_TYPES and GENERATOR in the two directories and checking each matching location to see whether the logic would better be implemented using GENERATOR_IS_MULTI_CONFIG. A few places under the Tests directory needed to support CMake versions older than 3.9 because the developer building CMake could use an older CMake to build CMake rather than using the bootstrap script. For those locations, if an older CMake is used then the logic falls back to the old method that relies on CMAKE_CONFIGURATION_TYPES just for the parts where this cannot be avoided. Most tests themselves will still use GENERATOR_IS_MULTI_CONFIG.

Fixes: #17134 (closed)

Edited by Craig Scott

Merge request reports