vcpgk
cmake スクリプトからトリプレットを選択したいと思います。ただし、2 つの問題に直面しました。
VCPKG_TARGET_TRIPLET
後に設定した場合project()
cmake_minimum_required(VERSION 3.5)
project(xxx CXX)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "----------------- x64")
set(__ARCH "x64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "----------------- x86")
set(__ARCH "x86")
else()
set(__ARCH "xUNKNOWN")
message(STATUS "----------------- xUNKNOWN")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(VCPKG_TARGET_TRIPLET "${__ARCH}-windows-static-md" CACHE STRING "target triplet" FORCE)
message(STATUS "Target triplet for debug is " ${VCPKG_TARGET_TRIPLET})
else()
set(VCPKG_TARGET_TRIPLET "${__ARCH}-windows-static" CACHE STRING "target triplet" FORCE)
message(STATUS "Target triplet for release is " ${VCPKG_TARGET_TRIPLET})
endif(CMAKE_BUILD_TYPE MATCHES Debug)
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
endif()
find_package(Protobuf REQUIRED)
エラーが発生する
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
VCPKG_TARGET_TRIPLET
以前に設定した場合project()
、期待どおりに動作しますが、x64 か x86 かを判断できません
cmake_minimum_required(VERSION 3.5)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "----------------- x64")
set(__ARCH "x64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "----------------- x86")
set(__ARCH "x86")
else()
set(__ARCH "xUNKNOWN")
message(STATUS "----------------- xUNKNOWN")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(VCPKG_TARGET_TRIPLET "${__ARCH}-windows-static-md" CACHE STRING "target triplet" FORCE)
message(STATUS "Target triplet for debug is " ${VCPKG_TARGET_TRIPLET})
else()
set(VCPKG_TARGET_TRIPLET "${__ARCH}-windows-static" CACHE STRING "target triplet" FORCE)
message(STATUS "Target triplet for release is " ${VCPKG_TARGET_TRIPLET})
endif(CMAKE_BUILD_TYPE MATCHES Debug)
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
endif()
project(xxx CXX)
find_package(Protobuf REQUIRED)
そして、このプリントを入手してください
----------------- xUNKNOWN
PS: 環境-DVCPKG_TARGET_TRIPLET=<>
が原因で使用できません。制限。これは構成中に検出する必要があります