Skip to content

Commit e7ce72a

Browse files
committed
fix windows build due to protobuf find failure
1 parent c751088 commit e7ce72a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

LegacyFindPackages.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ if (VCPKG_TRIPLET)
2323
set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/vcpkg_installed/${VCPKG_TRIPLET}")
2424
message(STATUS "Use CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
2525
set(PROTOC_PATH "${CMAKE_PREFIX_PATH}/tools/protobuf/protoc")
26+
if (MSVC AND VCPKG_TRIPLET MATCHES ".*-static")
27+
# vcpkg installs host executables (protoc, etc.) in the non-static triplet's
28+
# tools directory. Derive it by stripping "-static" from the triplet name.
29+
string(REPLACE "-static" "" VCPKG_HOST_TRIPLET "${VCPKG_TRIPLET}")
30+
set(PROTOC_PATH "${PROJECT_SOURCE_DIR}/vcpkg_installed/${VCPKG_HOST_TRIPLET}/tools/protobuf/protoc")
31+
# Set the cache variable so protobuf's CMake module compatibility shim finds it
32+
set(Protobuf_PROTOC_EXECUTABLE "${PROTOC_PATH}.exe" CACHE FILEPATH "protoc executable" FORCE)
33+
endif ()
2634
message(STATUS "Use protoc: ${PROTOC_PATH}")
2735
set(VCPKG_ROOT "${PROJECT_SOURCE_DIR}/vcpkg_installed/${VCPKG_TRIPLET}")
2836
set(VCPKG_DEBUG_ROOT "${VCPKG_ROOT}/debug")

0 commit comments

Comments
 (0)