如何修复 'Vcpkg/CMake Is Unable to determine target architecture' (Windows10,vcpkg,clion,cmake)
How to fix 'Vcpkg/CMake Is Unable to determine target architecture' (Windows10,vcpkg,clion,cmake)
我想使用这个库见:https://github.com/jtv/libpqxx
我决定安装这个库管理器 vcpkg 请参阅:https://github.com/microsoft/vcpkg
我将 CMake 选项设置为 "CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake"
这是错误:
"C:\Program Files\JetBrains\CLion 2019.1.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/vcpkg/scripts /buildsystems/vcpkg.cmake -G "CodeBlocks - MinGW Makefiles" C:\Users \Vaio\CLionProjects\untitled
CMake Warning at C:/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake:68 (message):
Unable to determine target architecture, continuing without vcpkg.
Call Stack (most recent call first):
cmake-build-debug-mingw/CMakeFiles/3.14.3/CMakeSystem.cmake:6 (include)
CMakeLists.txt:2 (project)
对应的CMake代码是这样的:
if(VCPKG_TARGET_TRIPLET)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 Win64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 ARM$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 16 2019$")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Xx]86$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Mm][Dd]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Rr][Mm]$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Rr][Mm]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
endif()
else()
find_program(_VCPKG_CL cl)
if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(_VCPKG_CL MATCHES "arm/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(_VCPKG_CL MATCHES "arm64/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
else()
if( _CMAKE_IN_TRY_COMPILE )
message(STATUS "Unable to determine target architecture, continuing without vcpkg.")
else()
message(WARNING "Unable to determine target architecture, continuing without vcpkg.")
endif()
set(VCPKG_TOOLCHAIN ON)
return()
endif()
endif()
endif()
这是我所做的一步一步的。
- 已安装 Visual Studio 2019
- 已安装GIT
- 已安装 CMake
- 已安装的 vcpkg 请参阅:https://github.com/microsoft/vcpkg
安装命令:.\bootstrap-vcpkg.bat
5 运行:vcpkg 安装 libpqxx --triplet x64-windows
- 运行 : vcpkg list // 以查看是否已安装
- 运行 : vcpkg 集成安装
- 在 CLion/CMake
中指定了 -DCMAKE-TOOLCHAIN-FILE
我正在使用 MinGW/GNU 作为编译器
有什么我遗漏的吗?或者为什么它找不到我的目标架构?
这是我的环境变量。
注意:Visual Studio 2019
内一切正常
我在 -DCMAKE_TOOLCHAIN_FILE
之前添加了 -DVCPKG_TARGET_TRIPLET=x64-windows
并且有效。
现在我只需要弄清楚如何 link 包括但我想这是另一个问题。
link 解决方法:
https://vcpkg.readthedocs.io/en/latest/users/integration/
使用 CMake,您可以在配置行上设置 VCPKG_TARGET_TRIPLET
:
cmake ../my/project -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=...
如果你使用VCPKG_DEFAULT_TRIPLET
环境变量来控制vcpkg命令行中不合格的三元组你可以在CMake中默认[=14=] like
使用环境变量而不是命令行选项:
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()
我想使用这个库见:https://github.com/jtv/libpqxx
我决定安装这个库管理器 vcpkg 请参阅:https://github.com/microsoft/vcpkg
我将 CMake 选项设置为 "CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake"
这是错误:
"C:\Program Files\JetBrains\CLion 2019.1.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/vcpkg/scripts /buildsystems/vcpkg.cmake -G "CodeBlocks - MinGW Makefiles" C:\Users \Vaio\CLionProjects\untitled
CMake Warning at C:/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake:68 (message):
Unable to determine target architecture, continuing without vcpkg.
Call Stack (most recent call first):
cmake-build-debug-mingw/CMakeFiles/3.14.3/CMakeSystem.cmake:6 (include)
CMakeLists.txt:2 (project)
对应的CMake代码是这样的:
if(VCPKG_TARGET_TRIPLET)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 Win64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 ARM$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 16 2019$")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Xx]86$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Mm][Dd]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Rr][Mm]$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Rr][Mm]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
endif()
else()
find_program(_VCPKG_CL cl)
if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(_VCPKG_CL MATCHES "arm/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(_VCPKG_CL MATCHES "arm64/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
else()
if( _CMAKE_IN_TRY_COMPILE )
message(STATUS "Unable to determine target architecture, continuing without vcpkg.")
else()
message(WARNING "Unable to determine target architecture, continuing without vcpkg.")
endif()
set(VCPKG_TOOLCHAIN ON)
return()
endif()
endif()
endif()
这是我所做的一步一步的。
- 已安装 Visual Studio 2019
- 已安装GIT
- 已安装 CMake
- 已安装的 vcpkg 请参阅:https://github.com/microsoft/vcpkg 安装命令:.\bootstrap-vcpkg.bat 5 运行:vcpkg 安装 libpqxx --triplet x64-windows
- 运行 : vcpkg list // 以查看是否已安装
- 运行 : vcpkg 集成安装
- 在 CLion/CMake 中指定了 -DCMAKE-TOOLCHAIN-FILE
我正在使用 MinGW/GNU 作为编译器
有什么我遗漏的吗?或者为什么它找不到我的目标架构? 这是我的环境变量。
注意:Visual Studio 2019
内一切正常我在 -DCMAKE_TOOLCHAIN_FILE
之前添加了 -DVCPKG_TARGET_TRIPLET=x64-windows
并且有效。
现在我只需要弄清楚如何 link 包括但我想这是另一个问题。
link 解决方法: https://vcpkg.readthedocs.io/en/latest/users/integration/
使用 CMake,您可以在配置行上设置 VCPKG_TARGET_TRIPLET
:
cmake ../my/project -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=...
如果你使用VCPKG_DEFAULT_TRIPLET
环境变量来控制vcpkg命令行中不合格的三元组你可以在CMake中默认[=14=] like
使用环境变量而不是命令行选项:
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()