Я пытаюсь использовать CMAKE с Visual Studio Buildtools 2017; и независимо от того, какая комбинация флагов или иным образом я не могу получить рабочую компиляцию. (Я тоже пробовал buildtools 2015) Я не могу получить доступ к библиотекам UWP, в частности platform.winmd
Я всегда заканчиваю
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]
Мой CMAKELISTS.txt выглядит так:
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})
И я удалил весь источник, кроме пустой функции и вызова для включения #include <collection.h>
CMake сам называется так:
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"
Полный вывод при исполнении:
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"
> [email protected] compile C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test
> 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) ->
"C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj" (default target) (3) ->
(ClCompile target) ->
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
я имею
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/lib/x86/store/references/platform.winmd
И я попытался включить их в качестве библиотек с
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")
Но ничего из этого тоже ничего не делает.
Также не установка CMAKE_SYSTEM_NAME
set( CMAKE_SYSTEM_NAME WindowsStore )
или CMAKE_SYSTEM_VERSION
set( CMAKE_SYSTEM_VERSION 10.0 )
Я даже попытался установить библиотеку для каждого каталога, который я мог найти в файле sdk.bat:
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" )
Но это было не так.
Так что теперь я уверен, что упустил что-то очевидное. Так что я надеюсь, что кто-нибудь может помочь мне здесь! Спасибо!
(кстати, cmake-js
это интерфейс для cmake, он просто передает флаги прямо в cmake и не должен влиять на систему, но просто чтобы убедиться, что я попытался запустить cmake напрямую, с теми же результатами)
Согласно документации Microsoft, указать каталоги метаданных, Вы должны передать опцию компилятора -AI"directory-path"
для библиотек winmd. В случае Visual C ++ 2017 попробуйте расширить параметры C ++ в файле CMakeLists.txt следующим образом:
# windows.winmd search path:
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AI\"C:/Program Files (x86)/Windows Kits/10/UnionMetadata\"" )
# platform.winmd search path for MSVC 2017:
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AI\"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/VC/vcpackages\"" )
Я протестировал эти два пути поиска только в Visual Studio 2017 и Windows 10. Вам придется изменить один или, возможно, оба пути, если у вас разные версии.
Других решений пока нет …