Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 23, 2025

Problem

The GitHub Actions workflows were failing with CMake compilation errors when building with tests enabled:

CMake Error at build/Release/_deps/googletest-src/CMakeLists.txt:4 (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.

This error occurs when newer CMake versions (3.31+) encounter older dependency projects like GoogleTest that specify very old minimum required versions that are no longer supported.

Solution

Added a conditional setting of CMAKE_POLICY_VERSION_MINIMUM to the main CMakeLists.txt:

# Set CMAKE_POLICY_VERSION_MINIMUM if not already defined to avoid compatibility issues
# with newer CMake versions when fetching dependencies like GoogleTest
if(NOT DEFINED CMAKE_POLICY_VERSION_MINIMUM)
    set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
endif()

Key Features

  • Conditional Logic: Only sets the policy version when not already defined, preserving explicit user configurations
  • Minimal Impact: Adds only 6 lines of code with clear documentation
  • Backward Compatible: Existing scripts like run_tests.sh that already set this parameter continue to work unchanged
  • Future-Proof: Handles newer CMake versions gracefully while maintaining compatibility

Testing

Verified the fix works across multiple scenarios:

  • ✅ Fresh builds without any CMAKE_POLICY_VERSION_MINIMUM setting
  • ✅ Builds with explicit CMAKE_POLICY_VERSION_MINIMUM override
  • ✅ Debug and Release configurations
  • ✅ Existing test scripts continue to function
  • ✅ All unit tests pass successfully

Impact

This resolves the CI/CD pipeline failures and ensures that GitHub Actions workflows can build the project with tests enabled without requiring manual parameter configuration. Local development workflows remain unchanged.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Set CMAKE_POLICY_VERSION_MINIMUM=3.5 when not already defined to prevent
CMake compatibility errors when fetching GoogleTest dependencies.
This resolves the build failure that occurs with newer CMake versions.

Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
Copilot AI changed the title [WIP] 你的任务: 解决流水线里面 cmake 编译的报错问题。 描述:我的任务设置了 github workflow, 运行时有下面的报错: ``` -- ccap: Using bundled GLFW -- ccap: GLFW available: ON -- ccap: Add example: 0-print_camera -- ccap... Fix CMake policy version compatibility issue with GoogleTest dependencies Sep 23, 2025
Copilot AI requested a review from wysaid September 23, 2025 10:06
@wysaid wysaid marked this pull request as ready for review September 23, 2025 12:39
Copilot AI review requested due to automatic review settings September 23, 2025 12:39
@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes CMake compatibility issues with newer CMake versions (3.31+) when building with GoogleTest dependencies by setting a minimum policy version.

  • Adds conditional CMAKE_POLICY_VERSION_MINIMUM setting to avoid compatibility errors
  • Preserves backward compatibility and existing user configurations
  • Resolves CI/CD pipeline failures when building with tests enabled

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wysaid wysaid merged commit 571cd02 into main Sep 23, 2025
25 checks passed
@wysaid wysaid deleted the copilot/fix-58494bec-a081-4be6-9d85-35b6b7846eb6 branch September 23, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants