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?
Ok, you have hit quite a lot bugs here. Lets sum them up:
1)
$(VCRoot)\$(VCVersion)\bin\Hostx64\x64
gets expanded into
"C:\Program Files\Microsoft Visual Studio 2017\VC\Tools\MSVC"\14.13.26128\bin\Hostx64\x64\cl.exe
I hate windows for using spaces in important paths, but this is clearly a bug
2) However there's still one problem. When codeblocks launches, it pops up a warning that it can't find the compiler in the executable search path. I assume this is either because the executables are not in a "bin" folder. They're in a folder named something like "...\bin\Hostx64\x64" or "...\bin\Hostx86\x64". Or it could be the variables in the paths aren't expanded in the check done when codeblocks starts.
can you open two tickets on Source forge so they wont get lost?
i will try to look into them as soon as i find some time... (but there still needs to be a dev to review them and merge them into trunk)