Skip to content

Commit

Permalink
[windows CI] get protobuf binaries from external source
Browse files Browse the repository at this point in the history
  • Loading branch information
em-eight committed Sep 24, 2023
1 parent 94fdac9 commit cd6b051
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,31 @@ jobs:
run: choco install -y llvm
if: runner.os == 'Windows'

- name: windows vcpkg shit
# https://vcpkg.io/en/getting-started.html
- name: Download protobuf
run: |
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
vcpkg install protobuf protobuf:x64-windows
vcpkg owns protobuf
ls vcpkg/scripts/buildsystems/vcpkg.cmake
Invoke-WebRequest "https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-win64.zip" -OutFile protoc_x64-windows.zip
dir
mkdir protoc_x64-windows
7z x protobuf_x64-windows.zip -oprotoc_x64-windows
dir
Invoke-WebRequest "https://www.dropbox.com/scl/fi/te9p80zrzcwgswrkw21en/protobuf_x64-windows.zip?rlkey=btmzjokhh256xxns348o3re7m&dl=1" -OutFile protobuf_x64-windows.zip
dir
7z x protobuf_x64-windows.zip
dir
- name: CMake generate
env:
ARTIFACT_NAME: ppc2cpp-${{ runner.os }}
run: |
echo $WINDOWS_FLAGS
cmake --version
cmake -B build \
-DCMAKE_INSTALL_PREFIX=$ARTIFACT_NAME \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-S . -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_GENERATOR_PLATFORM=x64
-DEXTERNAL_LIBPROTOBUF_PATH=protobuf_x64-windows \
-DEXTERNAL_PROTOC_PATH=protoc_x64-windows \
shell: bash
- name: Build
run: cmake --build build --target install -j
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ CPMAddPackage("gh:fmtlib/fmt#10.0.0")

set(Protobuf_USE_STATIC_LIBS ON)

if(DEFINED EXTERNAL_LIBPROTOBUF_PATH AND DEFINED EXTERNAL_PROTOC_PATH)
# In case protobuf location is defined externally
find_package(Protobuf) # fails but defines protobuf_generate_cpp lmaoooo
link_directories(${EXTERNAL_LIBPROTOBUF_PATH}/lib)
set(Protobuf_LIBRARIES protobuf)
set(Protobuf_INCLUDE_DIRS "${EXTERNAL_LIBPROTOBUF_PATH}/include")
set(Protobuf_PROTOC_EXECUTABLE "${EXTERNAL_PROTOC_PATH}/bin/protoc.exe")
set(protobuf_MODULE_COMPATIBLE ON)
else()
find_package(protobuf CONFIG)
if(NOT protobuf_FOUND) # Legacy protobuf support
message(STATUS "Trying legacy method of finding protobuf")
set(protobuf_MODULE_COMPATIBLE ON)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
endif()
endif()

# Generate Protobuf files
set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/proto")
Expand Down

0 comments on commit cd6b051

Please sign in to comment.