Skip to content

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

@xoloki

Description

@xoloki

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions