[英]Why can't i get cmake to work with vcpkg in vs code without VS Generator
My DCMAKE_TOOLCHAIN_FILE option is set appropiately.我的DCMAKE_TOOLCHAIN_FILE选项设置得当。 Intellisense recognises the library that i am using and yet i can't seem to get it working. Intellisense 识别出我正在使用的库,但我似乎无法让它工作。 Usually i get.通常我得到。 If i don't set the target architecture it goes on to build without vcpkg.如果我没有设置目标架构,它会在没有 vcpkg 的情况下继续构建。 If i do try to set it it says that it is not supported by the genrator which is actually to be expected since in the cmake --help ony The VS generators have the [Arch] tag如果我确实尝试设置它,它表示生成器不支持它,这实际上是可以预期的,因为在cmake --help ony VS 生成器具有[Arch]标签
CmakeLists.txt CmakeLists.txtPS D:\.WorkSpaces\KeyHUD> cmake -G "MinGW Makefile" -A=Win32 "-DCMAKE_TOOLCHAIN_FILE=D:\.Installs\vcpkg\scripts\buildsystems\vcpkg.cmake"
CMake Error: Could not create named generator MinGW Makefile
Generators
Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
Use -A option to specify architecture.
* Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Borland Makefiles = Generates Borland makefiles.
NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
Unix Makefiles = Generates standard UNIX makefiles.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
Ninja = Generates build.ninja files.
Ninja Multi-Config = Generates build-<Config>.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles JOM
= Generates CodeBlocks project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - MinGW Makefiles = Generates CodeLite project files.
CodeLite - NMake Makefiles = Generates CodeLite project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Sublime Text 2 - MinGW Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - NMake Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
Comand 1 i tried and its output
我尝试过的命令 1 及其 output
D:\.WORKSPACES\KEYHUD
├───.vscode
├───build
├───CMakeFiles
│ └───3.17.0
|───raster
|───main.cpp
Command 2 and its output
命令2及其output
PS D:\.WorkSpaces\KeyHUD\build> cmake "-DCMAKE_TOOLCHAIN_FILE=D:\.Installs\vcpkg\scripts\buildsystems\vcpkg.cmake".. CMake Warning at D:/.Installs/vcpkg/scripts/buildsystems/vcpkg.cmake:85 (message): Unable to determine target architecture, continuing without vcpkg. Call Stack (most recent call first): CMakeFiles/3.17.0/CMakeSystem.cmake:6 (include) CMakeLists.txt:4 (project) CMake Error at CMakeLists.txt:4 (project): Generator MinGW Makefiles does not support platform specification, but platform =Win32 was specified. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred: See also "D./.WorkSpaces/KeyHUD/CMakeFiles/CMakeOutput.log".
Folder structure文件夹结构
D:\.WORKSPACES\KEYHUD ├───.vscode ├───build ├───CMakeFiles │ └───3.17.0 |───raster |───main.cpp
You need to define VCPKG_TARGET_TRIPLET
in your cmake call (probably x64-mingw) to avoid the warning and drop the -A=Win32
您需要在 cmake 调用(可能是 x64-mingw)中定义VCPKG_TARGET_TRIPLET
以避免警告并删除-A=Win32
also cmake -G "MinGW Makefile"
has a typo it should be cmake -G "MinGW Makefiles"
(missing the s)还有cmake -G "MinGW Makefile"
有错字,应该是cmake -G "MinGW Makefiles"
(缺少 s)
so try:所以试试:
cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=D:\.Installs\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-mingw
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.