diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 115b0c4..4ee5988 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -15,31 +15,37 @@ jobs: - name: Install LLVM run: choco install -y llvm - if: runner.os == 'Windows' + - name: Install Ninja + run: choco install -y ninja - - 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 + shell: bash env: ARTIFACT_NAME: ppc2cpp-${{ runner.os }} run: | - echo $WINDOWS_FLAGS - cmake --version - cmake -B build \ + cmake -B build -GNinja \ -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 - shell: bash + -DEXTERNAL_LIBPROTOBUF_PATH=protobuf_x64-windows \ + -DEXTERNAL_PROTOC_PATH=protoc_x64-windows + cat build/build.ninja - name: Build - run: cmake --build build --target install -j + shell: bash + run: cmake --build build --target install --parallel - uses: actions/upload-artifact@v3 if: github.ref == 'refs/heads/main' && github.repository == 'em-eight/ppc2cpp' diff --git a/CMakeLists.txt b/CMakeLists.txt index d584446..1eac65c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,17 @@ 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 (Windows/CI hack) + 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") + add_executable(protobuf::protoc IMPORTED) + set_target_properties(protobuf::protoc PROPERTIES IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}") + 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 +52,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")