Behavioral difference between cmake.exe and cmake-gui.exe when setting CMAKE_GENERATOR_{TOOLSET,PLATFORM}
Affected version: CMake version 3.15.1
Attempting to set CMAKE_GENERATOR_TOOLSET
and/or CMAKE_GENERATOR_PLATFORM
from within CMakeLists.txt
results in a behavioral difference between the command line and GUI CMake clients. In particular, it appears that cmake-gui
caches the user-provided toolset and platform inputs after the first configure step, even if empty, and becomes confused on subsequent configure steps. In contrast, cmake
exhibits the correct behavior; i.e. retaining the explicitly set variables.
The error produced by cmake-gui.exe
on Windows 10 when building using the Visual Studio 15 2017 generator is:
CMake Error: Error: generator platform:
Does not match the platform used previously: x64
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
The attached CMakeLists.txt
is a minimal repro of the error.