microsoft / cppgraphqlgen

C++ GraphQL schema service generator
MIT License
325 stars 45 forks source link

Build failed in Visual Studio 2019 - Missing Boost_INCLUDE_IDR program_options #111

Closed sammi closed 4 years ago

sammi commented 4 years ago

Visual studio 2019 Build Error: Target: x64-Debug

Error:

Severity Code Description Project File Line Suppression State Error CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message): Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options) C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake 164

Visual Studio 2019 latest Preview Build Error:

Target: x64-Debug

Severity Code Description Project File Line Suppression State Error CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message): Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options) C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake 164

wravery commented 4 years ago

You have to install the dependencies and somehow tell CMake where they are. By far the easiest way to do that when you're using Visual Studio 2019 is to install them with vcpkg.

You can actually install cppgraphqlgen that way too. If you use vcpkg install --head cppgraphqlgen it should even be up to date with changes that haven't been integrated yet in the vcpkg port.

sammi commented 4 years ago

I figured it out by the following two steps:

  1. install boost and other lib by vcpkg
    cd C:/Users/songy/cloud/vcpkg
    vcpkg install pegtl boost-program-options boost-filesystem rapidjson gtest 
  2. using vcpkg.cmake in camkeToolchain
    {
    "configurations": [
    {
      "name": "x86-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "",
      "ctestCommandArgs": "",
      "cmakeToolchain": "C:/Users/songy/cloud/vcpkg/scripts/buildsystems/vcpkg.cmake",
      "inheritEnvironments": [ "msvc_x86" ],
      "variables": []
    }
    ]
    }