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.
The problem is a migration from this issue
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
- Create empty folder with
CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.24)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake")
project(Test)
And toolchain.cmake
file with contents:
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()
-
Load project from CMake GUI
-
Delete cache through
File
→Delete Cache
-
Press
Configure
button -
Use this settings (or another from log):
-
Press
Finish
-
Wait for configure is finished
-
Press
Configure
button again -
See the error