From cd6b05116163cdc4a10f6767989c338a29d008ca Mon Sep 17 00:00:00 2001 From: em-eight Date: Sun, 24 Sep 2023 18:59:55 +0300 Subject: [PATCH] [windows CI] get protobuf binaries from external source --- .github/workflows/windows.yml | 23 ++++++++++++++--------- CMakeLists.txt | 10 ++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 115b0c4..c9818db 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index d584446..0f110cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,15 @@ 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") @@ -41,6 +50,7 @@ if(NOT protobuf_FOUND) # Legacy protobuf support include(FindProtobuf) find_package(Protobuf REQUIRED) endif() +endif() # Generate Protobuf files set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/proto")