我想使用这个库见:https://github.com/jtv/libpqxx
我决定安装这个库管理器 vcpkg 见:https://github.com/microsoft/vcpkg
我将 CMake Option 设置为“CMake 项目应该使用:”-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()
这是我所做的一步一步。
安装命令:.\bootstrap-vcpkg.bat
5 运行: vcpkg install libpqxx --triplet x64-windows
我使用 MinGW/GNU 作为编译器
有什么我错过了吗?或者为什么找不到我的目标架构?
这是我的环境变量。
注意:一切都在 Visual Studio 2019 中运行
最佳答案
我在 -DVCPKG_TARGET_TRIPLET=x64-windows
之前添加了 -DCMAKE_TOOLCHAIN_FILE
并且它起作用了。
现在我只需要弄清楚如何链接包含,但我想这是另一个问题。
解决方法链接:
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 中默认使用 VCPKG_TARGET_TRIPLET
,例如使用环境变量而不是命令行选项:
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()
关于c++ - 如何修复 'Vcpkg/CMake Is Unable to determine target architecture'(Windows10、vcpkg、clion、cmake),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57092692/