cmake_install.cmake using wrong CMAKE_INSTALL_CONFIG_NAME

Hey,
I use CMake 3.17.2 on Windows with the generator “Visual Studio 14 2015 Win64”.

When I create my project, CMake also creates the file cmake_install.cmake.
This file contains the wrong default CMAKE_INSTALL_CONFIG_NAME. It is set to “Release” for me, but I create a “Debug” project. I can see from the (cryptic) source code that it should use CMAKE_BUILD_TYPE if nothing special is set.

This is how I call CMake:

cmake.exe -G "Visual Studio 14 2015 Win64"
  -DCMAKE_INSTALL_PREFIX=install
  -DCMAKE_TOOLCHAIN_FILE=HIDDEN/msbuild.cmake
  -DCMAKE_PREFIX_PATH=SOMEPATHS
  -DCMAKE_BUILD_TYPE=Debug
  -DBUILD_SHARED_LIBS=ON
  path/to/source

And the cmake_install.cmake then contains:

...
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
  if(BUILD_TYPE)
    string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
           CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
  else()
    set(CMAKE_INSTALL_CONFIG_NAME "Release")
  endif()
  message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
...

Can anyone tell me why this is the case and how I get a “Debug” as default?

This does nothing with the Visual Studio generator.

This comes from the first element of the CMAKE_CONFIGURATIONS list. Feel free to set its ordering as you see fit in your top-level CMakeLists.txt file.

1 Like

Ahhhh, I set CMAKE_CONFIGURATION_TYPES=Debug and it works!
Thank you very much!