libp2p / libp2p/cpp-libp2p

`Protobuf` dependency doesn't work with `cmake` from `brew` on `MacOS`

Open
#324 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
492
Forks
130
PR merge metrics
No merged PRs in 30d

Description

Summary

Trying to build with cmake from brew on MacOS, on , we get the following error with the Protobuf dependency:

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

This is caused by the first line in the dependency's CMakeLists.txt:

cmake_minimum_required(VERSION 3.2)

This happens because cmake version 4 removed compatibility with CMake < 3.5, and brew on MacOS does not offer an older version of cmake.

Passing the suggested -DCMAKE_POLICY_VERSION_MINIMUM=3.5 on the command line does not fix this.

Expected behavior

Build is successful on MacOS using the current versions of tools available in the default package manager brew.

Actual behavior

Build fails with the above error, due to incompatibility between the Protobuf dependency and the current version of cmake available on this platform.

Relevant log output
-- [hunter] PROTOBUF_ROOT: /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/Install (ver.: 3.19.4-p0)
-- [hunter] Building Protobuf
loading initial cache file /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/cache.cmake
loading initial cache file /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/Build/Protobuf/args.cmake
-- The C compiler identification is AppleClang 17.0.0.17000013
-- The CXX compiler identification is AppleClang 17.0.0.17000013
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/Build/Protobuf/Build
[  6%] Creating directories for 'Protobuf-Release'
[ 12%] Performing download step (download, verify and extract) for 'Protobuf-Release'
-- verifying file...
       file='/Users/axoloki/.hunter/_Base/Download/Protobuf/3.19.4-p0/e5b797d/v3.19.4-p0.tar.gz'
-- File already exists and hash match (skip download):
  file='/Users/axoloki/.hunter/_Base/Download/Protobuf/3.19.4-p0/e5b797d/v3.19.4-p0.tar.gz'
  SHA1='e5b797dbc4e6ad92d0924ae86c130be4354c35b6'
-- extracting...
     src='/Users/axoloki/.hunter/_Base/Download/Protobuf/3.19.4-p0/e5b797d/v3.19.4-p0.tar.gz'
     dst='/Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/Build/Protobuf/Source'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 18%] No update step for 'Protobuf-Release'
[ 25%] No patch step for 'Protobuf-Release'
[ 31%] Performing configure step for 'Protobuf-Release'
loading initial cache file /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/cache.cmake
loading initial cache file /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/Build/Protobuf/args.cmake
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.


-- Configuring incomplete, errors occurred!
make[2]: *** [Protobuf-Release-prefix/src/Protobuf-Release-stamp/Protobuf-Release-configure] Error 1
make[1]: *** [CMakeFiles/Protobuf-Release.dir/all] Error 2
make: *** [all] Error 2

[hunter ** FATAL ERROR **] Build step failed (dir: /Users/axoloki/.hunter/_Base/15ca502/106fd1a/00f4bd3/Build/Protobuf
[hunter ** FATAL ERROR **] [Directory:/Users/axoloki/.hunter/_Base/Download/Hunter/0.25.3-qdrvm36/15ca502/Unpacked/cmake/projects/Protobuf]

------------------------------ ERROR -----------------------------
    https://hunter.readthedocs.io/en/latest/reference/errors/error.external.build.failed.html
------------------------------------------------------------------

CMake Error at /Users/axoloki/.hunter/_Base/Download/Hunter/0.25.3-qdrvm36/15ca502/Unpacked/cmake/modules/hunter_error_page.cmake:12 (message):
Call Stack (most recent call first):
  /Users/axoloki/.hunter/_Base/Download/Hunter/0.25.3-qdrvm36/15ca502/Unpacked/cmake/modules/hunter_fatal_error.cmake:20 (hunter_error_page)
  /Users/axoloki/.hunter/_Base/Download/Hunter/0.25.3-qdrvm36/15ca502/Unpacked/cmake/modules/hunter_download.cmake:623 (hunter_fatal_error)
  /Users/axoloki/.hunter/_Base/Download/Hunter/0.25.3-qdrvm36/15ca502/Unpacked/cmake/projects/Protobuf/hunter.cmake:200 (hunter_download)
  /Users/axoloki/.hunter/_Base/Download/Hunter/0.25.3-qdrvm36/15ca502/Unpacked/cmake/modules/hunter_add_package.cmake:62 (include)
  cmake/dependencies.cmake:36 (hunter_add_package)
  CMakeLists.txt:75 (include)
Possible Solution

Update the Protobuf dependency, or add a patch to the build process to address this issue.

Version

Error occurs with both tag v0.1.37 and master branch.

Would you like to work on fixing this bug ?

Yes

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with cmake/dependencies.cmake and the top-level CMakeLists.txt, then reproduce the Protobuf 3.19.4-p0 build using Homebrew CMake 4 on macOS. Inspect Hunter's Protobuf build configuration and its generated dependency CMakeLists.txt. Done means the project builds successfully with the current Homebrew CMake version without the reported compatibility error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.