I've been trying to find a good solution for this too. What I've tried so far is to define 4 custom variables:
WINSDKROOT="C:\Program Files (x86)\Windows Kits\10"
WINSDKVERSION=10.0.16299.0 (or whatever kit is being used)
VCROOT=(whatever path visual c++ was installed to)
VCVERSION=14.13.26128 (or whatever the current version is)
Then I set the compiler and resource compiler search path to:
$(VCRoot)\$(VCVersion)\include
$(WinSDKRoot)\include\$(WinSDKVersion)\shared
$(WinSDKRoot)\include\$(WinSDKVersion)\ucrt
$(WinSDKRoot)\include\$(WinSDKVersion)\um
and the linker search path to:
$(VCRoot)\$(VCVersion)\lib\x64
$(WinSDKRoot)\lib\$(WinSDKVersion)\ucrt\x64
$(WinSDKRoot)\lib\$(WinSDKVersion)\um\x64
This way whenever the visual c++ kit gets updated, I only have to change the VCVERSION variable. Likewise, when a new SDK is released, I only have to change the WINSDKVERSION variable.
The problem is that this doesn't work for the toolchain executable paths if they have spaces in them. For example if I try to set the compilers installation directory to
$(VCRoot)\$(VCVersion)\bin\Hostx64\x64
where VCRoot is something like "C:\Program Files\Microsoft Visual Studio 2017\VC\Tools\MSVC", the path for the compiler will get expanded to
"C:\Program Files\Microsoft Visual Studio 2017\VC\Tools\MSVC"\14.13.26128\bin\Hostx64\x64\cl.exe
Apparently windows doesn't like having part of the full path quoted and the rest unquoted, so when codeblocks tries to invoke the compiler with that command, it fails. So the only thing I think I can do is reset the compilers's installation directory setting in addition to changing the VCVERSION variable everytime visual c is upgraded.
Does anybody have a better solution?