Skip to content

Move missing vcpkg information to prerequisites #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions doc/setup/installing_prerequisites.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ Therefore, it could make sense to still dynamically link against the C Runtime w

The easiest way to achieve static linking on Windows without setting all the stuff manually in Cmake and building _protobuf_ is to actually **install static _protobuf_ with dynamic c-runtime with vcpkg**:

Install vcpkg as per the vcpkg documentation.
Create a new triplet file for the required combination of static library linking with dynamic runtime (usually needed for dynamic linking to still work):
Create a file named x64-windows-static-md.cmake in the triplets directory with the following content:

----
vcpkg install --triplet=x64-windows-static-md protobuf
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
----

Build::

For the cmake configuration, we can directly specify our vcpkg installation:
Now the protobuf libraries can be built automatically using:
----
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static-md -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -A x64
cmake --build . --config Release
vcpkg install --triplet=x64-windows-static-md protobuf
----

== Linux
Expand Down
6 changes: 6 additions & 0 deletions doc/setup/installing_windows_cpp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ cd build
cmake .. [-G <generator>] [-DCMAKE_INSTALL_PREFIX=<osi-install-directory>]
----
+
If you used vcpkg to install protobuf, then provide the target and toolchain file information, as follows
+
----
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static-md -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -A x64 [-G <generator>] [-DCMAKE_INSTALL_PREFIX=<osi-install-directory>]
----

. Build and install OSI.
+
----
Expand Down