This addresses issue #3805 as follows:
- Remove old detection code for CMake versions older than 2.6.3 to detect `cl_path`. This was hindering CMake from finding the correct `cl_path`.
- Ensure `cl_path` is defined before `cpp2asm_support.cmake` gets included, such that `ml.exe` and `ml64.exe` for x86 and x64 respectively are found in the correct path.
- Specify `cl_path` as a hint when trying to find `lib.exe` and `dumpbin.exe`.
- The Windows SDK that is being used may be installed into `C:\Program Files (x86)\Windows Kits\10`, of which the installation path is covered by a different registry key, namely `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots\KitsRoot10`. Check if the registry key points to an existing path, and use it as `kits_dir` if it does and then use that to derive the correct `sdk_bindir`. Otherwise fall back to the old method of detecting `sdk_bin` and `sdk_bindir`.
- When MFC is installed, this will try building drstats. Since drstats has hardcoded paths to `Uuid.Lib`, we now simply use `kits_dir` to specify the correct path to `Uuid.Lib`.
I have tested this with Tools for Visual Studio 2019 as follows:
```
git clone https://github.com/StephanvanSchaik/dynamorio -b i3805-msvc2019
cd dynamorio
mkdir build
cd build
cmake ..
cmd.exe
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64
msbuild.exe DynamoRIO.sln
```
This builds everything successfully. However, do note that you should not have Windows 11 SDK (version 10.0.22000.0) installed. Trying to build DynamoRIO against the Windows 11 SDK will fail with rc.exe emitting error RC2188 due to line 253 in `C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h`. See also: https://bugs.python.org/issue45220 (EDIT: the fix for this is to ensure `_AMD64_` or `_X86_` are defined when building).
Co-authored-by: Derek Bruening <[email protected]>
Fixes#3805