cmake deprecation_warning ai_generated true

CMake Warning (dev): Policy CMP0077 is not set: option() honors normal variables.

ID: cmake/policy-cmp-warning

Also available as: JSON · Markdown
88%Fix Rate
85%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3 active

Root Cause

CMake policy warning about deprecated behavior. Using OLD policy silences the warning but relies on behavior that will be removed.

generic

Workarounds

  1. 92% success Update code to comply with the NEW policy behavior
    cmake_policy(SET CMP0077 NEW)  # then update code to match new behavior

    Sources: https://cmake.org/cmake/help/latest/command/find_package.html

  2. 88% success Set cmake_minimum_required to a version where the policy defaults to NEW
    cmake_minimum_required(VERSION 3.24)  # CMP0077 defaults to NEW since 3.13
  3. 85% success Use cmake_policy(SET CMPxxxx NEW) explicitly in the relevant scope
    cmake_policy(SET CMP0077 NEW)  # only if you understand the behavioral change

Dead Ends

Common approaches that don't work:

  1. Set cmake_policy(SET CMPxxxx OLD) to suppress the warning 80% fail

    OLD behavior is deprecated and will be removed in future CMake versions. This is a ticking time bomb.

  2. Pin cmake_minimum_required to an old version to avoid the policy 85% fail

    Locks entire project to old CMake features and behavior, not just the single policy.