I am trying to set up custom build variants in vs code with CMake Tools extension. I have found some documentation about it here: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/variants.md. This is the content of cmake-variants.yaml file:
buildType:
default: debug
description: Build variants
choices:
debug:
short: Debug
long: Build with all debugging information included
buildType: Debug
release:
short: Release
long: Build with all debugging information stripped out
buildType: Release
As the documentation says, buildType is a string that will be set for CMAKE_BUILD_TYPE. So, for debug variant it should be set to "Debug" and for release it will be "Release". In my CMakeLists.txt I have this piece of code:
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(Sandbox PRIVATE "T_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /Zi /Od")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(Sandbox PRIVATE "T_RELEASE")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /MD")
endif()
None of this if statements ever work, so I guess CMAKE_BUILD_TYPE is either empty string or something other from "Debug" and "Release". What is the problem here? Is there some decent tutorial on how to set up the build variants correctly?