Skip to content

cmake-gui: empty generator or toolset fails on the reconfigure while set inside the script

Description

I need to load default valued inside the main CMakeLists.txt script.

If you keep generator & toolset values from CMake GUI empty, they really pass empty values.

If I correctly understand the #24864 (closed), this should work after upgrading to 3.29.0, but it really doesn't work.

Environment

CMake GUI 3.29.0 Windows 10 Pro Visual Studio 17 2022 generator

Error text from GUI log

  • Nothing was specified in generator & toolset
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.
  • generator was set as x64
CMake Error: Error: generator toolset: 
Does not match the toolset used previously: v143
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
  • both generator & toolset specified
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19045.
Configuring done (0.0s)

Steps to reproduce

  1. Create empty folder with CMakeLists.txt file:
cmake_minimum_required(VERSION 3.24)

if(NOT CMAKE_GENERATOR_TOOLSET)
    set(CMAKE_GENERATOR_TOOLSET "v143" CACHE INTERNAL "Visual Studio toolset to use for CMake")
endif()
if(NOT CMAKE_GENERATOR_PLATFORM)
    set(CMAKE_GENERATOR_PLATFORM "x64" CACHE INTERNAL "Visual Studio platform to use for CMake")
endif()

if(NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE)
    set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64" CACHE INTERNAL "Host architecture to use for CMake")
endif()

project(Test)
  1. Load project from CMake GUI
  2. Delete cache through File->Delete Cache
  3. Press Configure button
  4. Use this settings (or another from log): image
  5. Press Finish
  6. Wait for configure is finished
  7. Press Configure button again
  8. See the error
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information