Using vcpkg to properly build the required configurations of protobuf on Visual Studio (here VS 2017):
-
Install vcpkg as per the documentation, e.g. clone via git the bootstrap as needed
-
English Language pack needs to be installed for VS 2017 for vcpkg to work
-
Create a new triplet file for the required combination of static library linking with dynamic runtime (usually needed for dynamic linking to still work):
I had to create a file named x64-windows-static-md-v141.cmake in the triplets directory with the following content:
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_PLATFORM_TOOLSET "v141")
Note: only need the v141 suffix and setting of VCPKG_PLATFORM_TOOLSET to ensure VS 2017 is selected if you have newer VS installed (like I had).
-
Now the protobuf libraries can be built automatically using:
vcpkg.exe install protobuf:x64-windows-static-md-v141
-
Once built, they can be automatically used in building the examples by specifying the triplet and toolchain file from VCPKG on the cmake configuration command-line:
cd examples
mkdir wbuild
cd wbuild
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-v141 -DCMAKE_TOOLCHAIN_FILE=../../../vcpkg/scripts/buildsystems/vcpkg.cmake -G 'Visual Studio 15 2017 Win64'
cmake –build .
The CMAKE_TOOLCHAIN_FILE must point to your vcpkg directory, which in my example was parallel to the osi-sensor-model-packaging directory…
This might complain somewhat depending on cmake and compiler settings, but builds without problems (and should support release and debug builds out of the box).
Originally posted by @pmai in #519 (comment)
Using vcpkg to properly build the required configurations of protobuf on Visual Studio (here VS 2017):
Install vcpkg as per the documentation, e.g. clone via git the bootstrap as needed
English Language pack needs to be installed for VS 2017 for vcpkg to work
Create a new triplet file for the required combination of static library linking with dynamic runtime (usually needed for dynamic linking to still work):
I had to create a file named x64-windows-static-md-v141.cmake in the triplets directory with the following content:
Note: only need the v141 suffix and setting of VCPKG_PLATFORM_TOOLSET to ensure VS 2017 is selected if you have newer VS installed (like I had).
Now the protobuf libraries can be built automatically using:
Once built, they can be automatically used in building the examples by specifying the triplet and toolchain file from VCPKG on the cmake configuration command-line:
The CMAKE_TOOLCHAIN_FILE must point to your vcpkg directory, which in my example was parallel to the osi-sensor-model-packaging directory…
This might complain somewhat depending on cmake and compiler settings, but builds without problems (and should support release and debug builds out of the box).
Originally posted by @pmai in #519 (comment)