title: Using CMAKE with visual studio buildtools 2017 ; unable to access UWP libs
body: <p>I'm trying to to use CMAKE with Visual Studio Buildtools 2017; and no matter what combination of flags or otherwise I am unable to get a working compilation. (I tried buildtools 2015 as well) I'm unable to access UWP libs, specifically <code>platform.winmd</code></p>
  
  <p>I always end with</p>
  
  <pre><code>fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable [C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj]
  </code></pre>
  
  <p>My CMAKELISTS.txt looks like:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.7)
  set(lib "winsearch")
  file(GLOB SOURCE_FILES "src/module/winSearch/*.cpp" "src/module/winSearch/*.h")
  add_library( ${lib} SHARED ${SOURCE_FILES})
  set( MSVS15_COMPILE_FLAGS "/ZW" )
  SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVS15_COMPILE_FLAGS}" )
  set_target_properties(${lib} PROPERTIES PREFIX "" SUFFIX ".node")
  target_include_directories(${lib} PRIVATE ${CMAKE_JS_INC})
  target_link_libraries(${lib} ${CMAKE_JS_LIB})
  </code></pre>
  
  <p>And I have removed all the source except for a blank function and a call to include <code>#include &lt;collection.h&gt;</code></p>
  
  <p><strong>CMAKE</strong> itself is being called like:</p>
  
  <pre><code>cmake.exe "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test" --no-warn-unused-cli -G"Visual Studio 15 2017 Win64" -DCMAKE_JS_VERSION="3.4.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build" -DCMAKE_JS_INC="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\src;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\v8\include;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\uv\include;C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\node_modules\nan" -DNODE_RUNTIME="electron" -DNODE_RUNTIMEVERSION="1.4.5" -DNODE_ARCH="x64" -DCMAKE_JS_LIB="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\x64\node.lib"
  </code></pre>
  
  <p>The full output upon execution is:</p>
  
  <pre><code>info TOOL Using Visual Studio 15 2017 Win64 generator, as specified from commandline.
  info CMD CLEAN
  info RUN C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe -E remove_directory "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build"
  
  &gt; uwp-js-test@0.0.1 compile C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test
  &gt; cmake-js build -c "C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe" -G "Visual Studio 15 2017 Win64"
  
  info TOOL Using Visual Studio 15 2017 Win64 generator, as specified from commandline.
  info CMD CONFIGURE
  info RUN C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test" --no-warn-unused-cli -G"Visual Studio 15 2017 Win64" -DCMAKE_JS_VERSION="3.4.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build" -DCMAKE_JS_INC="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\src;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\v8\include;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\uv\include;C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\node_modules\nan" -DNODE_RUNTIME="electron" -DNODE_RUNTIMEVERSION="1.4.5" -DNODE_ARCH="x64" -DCMAKE_JS_LIB="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\x64\node.lib"
  Not searching for unused variables given on the command line.
  -- The C compiler identification is MSVC 19.10.24930.0
  -- The CXX compiler identification is MSVC 19.10.24930.0
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/build
  info CMD BUILD
  info RUN C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe --build "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build" --config Release
  Microsoft (R) Build Engine version 15.1.545.13942
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  Build started 2/18/2017 9:27:58 PM.
  Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" on node 1 (default targets).
  Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (1) is building "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-te st\build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
  PrepareForBuild:
    Creating directory "x64\Release\ZERO_CHECK\".
    Creating directory "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\".
  InitializeBuildStatus:
    Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
  CustomBuild:
    Checking Build System
    CMake does not need to re-run because C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/build/CMakeFiles/generate.stamp is up-to-date.
  FinalizeBuildStatus:
    Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
    Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
  Done Building Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ZERO_CHECK.vcxproj" (default targets).
  
  Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (1) is building "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-te st\build\winsearch.vcxproj" (3) on node 1 (default targets).
  PrepareForBuild:
    Creating directory "winsearch.dir\Release\".
    Creating directory "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\Release\".
    Creating directory "winsearch.dir\Release\winsearch.tlog\".
  InitializeBuildStatus:
    Creating "winsearch.dir\Release\winsearch.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
  CustomBuild:
    Building Custom Rule C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/CMakeLists.txt
    CMake does not need to re-run because C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/build/CMakeFiles/generate.stamp is up-to-date.
  ClCompile:
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.24930\bin\HostX86\x64\CL.exe /c /I"C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5
    \src" /I"C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\v8\include" /I"C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\uv\include" /I"C:\Users\ehiller\Dev\
    src\github.com\erichiller\uwp-js-test\node_modules\nan" /ZW /nologo /W3 /WX- /diagnostics:classic /O2 /Ob2 /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release
    \"" /D winsearch_EXPORTS /D _WINDLL /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"winsearch.dir\Release\\" /Fd"winsearch.dir\R
    elease\vc141.pdb" /Gd /TP /errorReport:queue "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\src\module\winSearch\winSearch.cpp"
    winSearch.cpp
  C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\src\module\winSearch\winSearch.cpp : fatal error C1107: could not find assembly 'platform.winmd': please sp ecify the assembly search path using /AI or by setting the LIBPATH environment variable [C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vc xproj]
  Done Building Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj" (default targets) -- FAILED.
  
  Done Building Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (default targets) -- FAILED.
  
  
  Build FAILED.
  
  "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (default target) (1) -&gt;
  "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj" (default target) (3) -&gt;
  (ClCompile target) -&gt;
    C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\src\module\winSearch\winSearch.cpp : fatal error C1107: could not find assembly 'platform.winmd': please
  specify the assembly search path using /AI or by setting the LIBPATH environment variable [C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch. vcxproj]
  
      0 Warning(s)
      1 Error(s)
  
  Time Elapsed 00:00:00.49
  </code></pre>
  
  <p>I have </p>
  
  <ul>
  <li><code>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd</code></li>
  <li><code>C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/lib/x86/store/references/platform.winmd</code></li>
  </ul>
  
  <p>And I tried including them as libraries with</p>
  
  <pre><code>target_link_libraries( ${lib} "C:/Program Files (x86)/Windows Kits/10/UnionMetadata/Windows.winmd" )
  
  TARGET_LINK_LIBRARIES(${lib} "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/lib/x86/store/references/platform.winmd")
  </code></pre>
  
  <p>But none of that does anything either.</p>
  
  <p>Nor does setting the <code>CMAKE_SYSTEM_NAME</code></p>
  
  <pre><code>set( CMAKE_SYSTEM_NAME WindowsStore )
  </code></pre>
  
  <p><em>or the <code>CMAKE_SYSTEM_VERSION</code></em></p>
  
  <pre><code>set( CMAKE_SYSTEM_VERSION 10.0 )
  </code></pre>
  
  <p>I even tried setting the library to every directory I could find in the sdk.bat file:</p>
  
  <pre><code>set( sd "C:/Program Files (x86)/Windows Kits/10/" )
  set( WindowsSDKVersion "10.0.14393.0" )
  
  target_link_libraries( ${lib} "${sd}bin")
  target_link_libraries( ${lib} "${sd}UnionMetadata")
  target_link_libraries( ${lib} "${sd}References")
  target_link_libraries( ${lib} "${sd}bin")
  
  target_link_libraries( ${lib} "{sd}bin" )
  target_link_libraries( ${lib} "${sd}UnionMetadata" )
  target_link_libraries( ${lib} "${sd}References" )
  target_link_libraries( ${lib} "${sd}lib/${WindowsSDKLibVersion}/um/${NODE_ARCH}" )
  
  
  target_link_libraries( ${lib} "${sd}include/${WindowsSDKVersion}/shared/" )
  target_link_libraries( ${lib} "${sd}include/${WindowsSDKVersion}/um/" )
  target_link_libraries( ${lib} "${sd}include/${WindowsSDKVersion}/winrt/" )
  
  target_link_libraries( ${lib} "${sd}References/CommonConfiguration/Neutral" )
  </code></pre>
  
  <p>But that wasn't it either.</p>
  
  <p>So I am at the point now that I am sure I missing something obvious. So I am hoping somebody can help me out here! Thanks!</p>
  
  <p><em>(by the way, the <code>cmake-js</code> is a frontend for cmake, it just passes the flags right along to cmake and should not affect the system, but just to make sure, I tried running cmake directly, with the same results)</em></p>