title: CMake vs vcpkg triplet selection
body: <p>I would like to select triplet for <code>vcpgk</code> from cmake scripts. However, I've faced with two problems.</p>
  
  <ol>
  <li>If I set <code>VCPKG_TARGET_TRIPLET</code> after <code>project()</code></li>
  </ol>
  
  <pre><code>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)
  </code></pre>
  
  <p>I get errors</p>
  
  <pre><code>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)
  </code></pre>
  
  <ol start="2">
  <li>If I set <code>VCPKG_TARGET_TRIPLET</code> before <code>project()</code>, it works as expected, but then I can't determine if it's x64 or x86</li>
  </ol>
  
  <pre><code>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)
  
  </code></pre>
  
  <p>And get this print</p>
  
  <pre><code>----------------- xUNKNOWN
  </code></pre>
  
  <p>PS: I can't use <code>-DVCPKG_TARGET_TRIPLET=&lt;&gt;</code> due to env. limitations. This has to be detected during configuration</p>