title: CMake try_compile() not finding correct Windows 10 SDK
body: <p>I am trying to compile <a href="https://github.com/SunburstApps/ReactOS" rel="nofollow noreferrer">my fork of ReactOS</a> using CMake 3.9.0-MSVC_2 (as included with Visual Studio 2017, 15.4 update). When I have CMake generate NMake makefiles or Ninja inputs, it works just fine. However, when I tell CMake to generate a Visual Studio 2017 solution, it fails with a weird error. Here's how to reproduce this issue:</p>
  
  <ol>
  <li>Clone <code>git@github.com:SunburstApps/ReactOS</code>. (It's a big repo, so please be patient. I have not been able to consistently reproduce this issue on a smaller project, in case anyone asks.)</li>
  <li>In the root of the project directory, run <code>configure.cmd VSSolution</code> from a VS2017 x86 C++ tools command prompt. This will tell CMake to generate a Visual Studio solution (the exact version is inferred from the copy of cl.exe in the path).</li>
  </ol>
  
  <p>I get the following CMake output:</p>
  
  <pre><code>-- The C compiler identification is unknown
  -- The CXX compiler identification is unknown
  CMake Error at CMakeLists.txt:24 (project):
    The CMAKE_C_COMPILER:
  
      cl
  
    is not a full path and was not found in the PATH.
  
  
  CMake Error at CMakeLists.txt:24 (project):
    The CMAKE_CXX_COMPILER:
  
      cl
  
    is not a full path and was not found in the PATH.
  
  
  
  -- Configuring incomplete, errors occurred!
  </code></pre>
  
  <p>Investigating the <code>CMakeError.log</code> file reveals the problem is actually something else. The vcxproj file that CMake generated to identify the compiler is refusing to link, complaining that <code>ucrtd.lib</code> can't be found. If I add the following line of code to the top-level CMakeLists.txt file, it will then progress slightly further (successfully identifying the compiler), only to die of the same issue during a <code>try_compile()</code> run to "detect compiler features".</p>
  
  <pre><code>set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0.15063.0)
  </code></pre>
  
  <p>I have come to the conclusion that CMake is generating files without the Windows SDK target platform set, which is causing VS to refuse to locate <code>ucrtd.lib</code>. The <code>set()</code> line above tells CMake to add that specific version to the vcxproj files it generates, but clearly it doesn't add it to all of them.</p>
  
  <p>I have tried other solutions I have found searching SO, including installing the Windows 8.1 SDK and running the CMake command as an administrator. Nothing helps. I need to generate a solution file so I can write code for this project using Visual Studio's excellent C++ editor. (I have also tried using the built-in CMake support in VS2017, but have found that it does not quite work due to ReactOS' specific cross-compiling requirements.) Can anyone give me some pointers? Thanks! </p>