diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9cce309..7c8c34e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,13 +90,13 @@ jobs: strategy: matrix: build_type: [Debug, Release] - os: [macos-latest, ubuntu-latest] + os: [macos-latest, ubuntu-20.04] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Install Linux dependencies if: startsWith(matrix.os, 'ubuntu') - run: sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev libabsl-dev + run: sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev - name: Install Mac dependencies if: startsWith(matrix.os, 'macos') run: brew install protobuf abseil @@ -138,7 +138,7 @@ jobs: if: steps.abseil-cache.outputs.cache-hit != 'true' run: | cd ~ - git clone https://github.com/abseil/abseil-cpp.git -b ${{ env.ABSEIL_VERSION }} abseil + git clone --depth=1 https://github.com/abseil/abseil-cpp.git -b ${{ env.ABSEIL_VERSION }} abseil cd ~/abseil && mkdir build && cd build cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_INSTALL_PREFIX=~/abseil-bin -DBUILD_SHARED_LIBS=${{ matrix.shared-lib }} -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded${{ matrix.build-type == 'Debug' && 'Debug' || '' }}${{ matrix.shared-lib == 'ON' && 'DLL' || '' }} -DCMAKE_CXX_STANDARD=17 .. nmake @@ -147,7 +147,7 @@ jobs: if: matrix.shared-lib == 'OFF' run: | cd ~ - git clone https://github.com/protocolbuffers/utf8_range.git utf8_range + git clone --depth=1 https://github.com/protocolbuffers/utf8_range.git utf8_range cd ~/utf8_range && mkdir build && cd build cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_INSTALL_PREFIX=~/utf8_range-bin -DCMAKE_CXX_STANDARD=17 -Dutf8_range_ENABLE_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -Dabsl_ROOT=~/abseil-bin -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded${{ matrix.build-type == 'Debug' && 'Debug' || '' }}' .. nmake @@ -156,7 +156,7 @@ jobs: if: steps.protobuf-cache.outputs.cache-hit != 'true' run: | cd ~ - git clone https://github.com/protocolbuffers/protobuf.git -b v${{ env.PROTOBUF_VERSION }} protobuf + git clone --depth=1 https://github.com/protocolbuffers/protobuf.git -b v${{ env.PROTOBUF_VERSION }} protobuf cd ~/protobuf && mkdir build && cd build cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=~/protobuf-bin -Dprotobuf_BUILD_SHARED_LIBS=${{ matrix.shared-lib }} -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_EXAMPLES=OFF -Dprotobuf_ABSL_PROVIDER=package -Dabsl_ROOT=~/abseil-bin -DABSL_PROPAGATE_CXX_STD=ON .. nmake diff --git a/.github/workflows/msvc_bin.yml b/.github/workflows/msvc_bin.yml deleted file mode 100644 index 9ad45d2..0000000 --- a/.github/workflows/msvc_bin.yml +++ /dev/null @@ -1,184 +0,0 @@ -name: Windows/MSVC binary generation - -on: - workflow_dispatch: - inputs: - protobuf_repo: - description: 'repo associated to the protobuf repo' - default: 'https://github.com/protocolbuffers/protobuf.git' - type: string - protobuf_branch: - description: 'branch associated with the protobuf repo' - default: 'main' - type: string - protobuf-c_repo: - description: 'repo associated to the protobuf-c repo' - default: 'https://github.com/protobuf-c/protobuf-c.git' - type: string - protobuf-c_branch: - description: 'branch associated with the protobuf-c repo' - default: 'master' - type: string - abseil_branch: - description: 'branch associated with the abseil-cpp repo' - default: 'master' - type: string - -defaults: - run: - shell: pwsh - -jobs: - build-binaries: - strategy: - matrix: - config: [Debug, Release] - shared_libs: [ON, OFF] - fail-fast: false - runs-on: windows-latest - steps: - - name: Set up an independent abseil repo - run: | - git clone --branch ${{ inputs.abseil_branch }} https://github.com/abseil/abseil-cpp.git - cd abseil-cpp - $runtime = 'MultiThreaded$<$:Debug>' - if ('${{ matrix.shared_libs }}' -eq 'ON') - { $runtime += 'DLL' } - cmake -DABSL_USE_EXTERNAL_GOOGLETEST=ON -DABSL_FIND_GOOGLETEST=ON ` - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DABSL_PROPAGATE_CXX_STD=ON ` - -DCMAKE_MSVC_RUNTIME_LIBRARY="$runtime" ` - -DCMAKE_CXX_STANDARD=17 -B build -A x64 -T host=x64 . - cmake --build build --config ${{ matrix.config }} - cmake --install build --config ${{ matrix.config }} --prefix "$Env:TMP/install/absl" - - - name: Set up the utf8 compression algorithm - if: ${{ matrix.shared_libs == 'OFF' }} - run: | - git clone https://github.com/protocolbuffers/utf8_range.git - cd utf8_range - cmake -DCMAKE_CXX_STANDARD=17 -Dutf8_range_ENABLE_TESTS=OFF ` - -DBUILD_SHARED_LIBS=OFF ` - -Dabsl_ROOT="$Env:TMP/install/absl" ` - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` - -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ` - -DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$:Debug>' ` - -B build -A x64 -T host=x64 . - cmake --build build --config ${{ matrix.config }} - cmake --install build --config ${{ matrix.config }} --prefix "$Env:TMP/install/utf8_range" - - - name: Set up protobuf repo - run: | - git clone --branch ${{ inputs.protobuf_branch }} --recurse-submodules ${{ inputs.protobuf_repo }} - cd protobuf - cmake -DCMAKE_CXX_STANDARD=17 ` - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} ` - -Dprotobuf_BUILD_TESTS=OFF ` - -Dprotobuf_BUILD_EXAMPLES=OFF ` - -Dprotobuf_ABSL_PROVIDER=package ` - -Dabsl_ROOT="$Env:TMP/install/absl" ` - -DABSL_PROPAGATE_CXX_STD=ON ` - -B build -A x64 -T host=x64 . - cmake --build build --config ${{ matrix.config }} - cmake --install build --config ${{ matrix.config }} --prefix "$Env:TMP/install/protobuf" - - - name: Set up protobuf-c repo - id: build - run: | - git clone --branch ${{ inputs.protobuf-c_branch }} --recurse-submodules ${{ inputs.protobuf-c_repo }} - cd protobuf-c - cmake -DCMAKE_CXX_STANDARD=17 ` - -DProtobuf_ROOT="$Env:TMP/install/protobuf" ` - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} ` - -DBUILD_TESTS=OFF ` - -Dabsl_ROOT="$Env:TMP/install/absl" ` - -Dutf8_range_ROOT="$Env:TMP/install/utf8_range" ` - -B build-cmake/build -A x64 -T host=x64 build-cmake - cmake --build build-cmake/build --config ${{ matrix.config }} - cmake --install build-cmake/build --config ${{ matrix.config }} --prefix "$Env:TMP/install/protobuf-c" - "BINARYDIR=$Env:TMP/install" | Out-File $Env:GITHUB_OUTPUT - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: protobuf-c-binaries-${{ matrix.config }}-${{ matrix.shared_libs == 'ON' && 'dll' || 'lib'}} - path: ${{ steps.build.outputs.BINARYDIR }} - - build-binaries-nmake: - strategy: - matrix: - config: [Debug, Release] - shared_libs: [ON, OFF] - fail-fast: false - runs-on: windows-latest - steps: - - - name: Enforce a developer console - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: amd64 - - - name: Set up an independent abseil repo - run: | - git clone --branch ${{ inputs.abseil_branch }} https://github.com/abseil/abseil-cpp.git - cd abseil-cpp - $runtime = 'MultiThreaded$<$:Debug>' - if ('${{ matrix.shared_libs }}' -eq 'ON') - { $runtime += 'DLL' } - cmake -DABSL_USE_EXTERNAL_GOOGLETEST=ON -DABSL_FIND_GOOGLETEST=ON ` - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DABSL_PROPAGATE_CXX_STD=ON ` - -DCMAKE_MSVC_RUNTIME_LIBRARY="$runtime" ` - -B build -DCMAKE_CXX_STANDARD=17 -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.config }} . - cmake --build build - cmake --install build --prefix "$Env:TMP/install/absl" - - - name: Set up the utf8 compression algorithm - if: ${{ matrix.shared_libs == 'OFF' }} - run: | - git clone https://github.com/protocolbuffers/utf8_range.git - cd utf8_range - cmake -DCMAKE_CXX_STANDARD=17 -Dutf8_range_ENABLE_TESTS=OFF ` - -DBUILD_SHARED_LIBS=OFF ` - -Dabsl_ROOT="$Env:TMP/install/absl" ` - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` - -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ` - -DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$:Debug>' ` - -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.config }} . - cmake --build build - cmake --install build --prefix "$Env:TMP/install/utf8_range" - - - name: Set up protobuf repo - run: | - git clone --branch ${{ inputs.protobuf_branch }} --recurse-submodules ${{ inputs.protobuf_repo }} - cd protobuf - cmake -DCMAKE_CXX_STANDARD=17 ` - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} ` - -Dprotobuf_BUILD_TESTS=OFF ` - -Dprotobuf_BUILD_EXAMPLES=OFF ` - -Dprotobuf_ABSL_PROVIDER=package ` - -Dabsl_ROOT="$Env:TMP/install/absl" ` - -DABSL_PROPAGATE_CXX_STD=ON ` - -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.config }} . - cmake --build build - cmake --install build --prefix "$Env:TMP/install/protobuf" - - - name: Set up protobuf-c repo - id: build - run: | - git clone --branch ${{ inputs.protobuf-c_branch }} --recurse-submodules ${{ inputs.protobuf-c_repo }} - cd protobuf-c - cmake -DCMAKE_CXX_STANDARD=17 ` - -DProtobuf_ROOT="$Env:TMP/install/protobuf" ` - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} ` - -DBUILD_TESTS=OFF ` - -Dabsl_ROOT="$Env:TMP/install/absl" ` - -Dutf8_range_ROOT="$Env:TMP/install/utf8_range" ` - -B build-cmake/build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.config }} build-cmake - cmake --build build-cmake/build - cmake --install build-cmake/build --prefix "$Env:TMP/install/protobuf-c" - "BINARYDIR=$Env:TMP/install" | Out-File $Env:GITHUB_OUTPUT - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: nmake-protobuf-c-binaries-${{ matrix.config }}-${{ matrix.shared_libs == 'ON' && 'dll' || 'lib'}} - path: ${{ steps.build.outputs.BINARYDIR }} diff --git a/build-cmake/CMakeLists.txt b/build-cmake/CMakeLists.txt index 1719916..1e7695c 100644 --- a/build-cmake/CMakeLists.txt +++ b/build-cmake/CMakeLists.txt @@ -19,21 +19,21 @@ FIND_PACKAGE(Protobuf REQUIRED) file(REAL_PATH "${PROTOBUF_INCLUDE_DIR}" PROTOBUF_INCLUDE_DIR) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) -find_package(absl REQUIRED) +find_package(absl CONFIG) # for static protobuf libraries include the dependencies if (Protobuf_USE_STATIC_LIBS) get_property(protobuf_ABSL_USED_TARGETS DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" PROPERTY IMPORTED_TARGETS) list(FILTER protobuf_ABSL_USED_TARGETS INCLUDE REGEX "absl::") - find_package(utf8_range REQUIRED) + find_package(utf8_range CONFIG) set(protobuf_UTF8_USED_TARGETS - utf8_range::utf8_validity - utf8_range::utf8_range + $ + $ ) elseif(WIN32) - set(protobuf_ABSL_USED_TARGETS absl::abseil_dll) + set(protobuf_ABSL_USED_TARGETS $) endif() #options @@ -129,7 +129,9 @@ if(WIN32) if(BUILD_SHARED_LIBS) set(OS_PATH_VARIABLE "$\\;${OS_PATH_VARIABLE}") - set(OS_PATH_VARIABLE "$\\;${OS_PATH_VARIABLE}") + if (TARGET absl::abseil_dll) + set(OS_PATH_VARIABLE "$\\;${OS_PATH_VARIABLE}") + endif() endif() else(WIN32)