Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,296
    • Issues 3,296
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 8
    • Merge Requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #21519

Closed
Open
Created Nov 29, 2020 by Craig Scott@craig.scottMaintainer

Help: Behavior of calling cmake_minimum_required() inside a function not fully documented

The documentation for the cmake_minimum_required() command contains this note:

Calling cmake_minimum_required() inside a function() limits some effects to the function scope when invoked. Such calls should not be made with the intention of having global effects.

I've been unable to find any further details in the docs about what those limitations are. As far as I can tell, calling cmake_minimum_required() inside a function should be well-defined. While functions create their own scope, that scope does not affect policies. Therefore, one would expect such a call to propagate the policy settings up to the caller's policy scope. This seems consistent with this comment from the cmake_policy() command's docs:

Commands created by the function() and macro() commands record policy settings when they are created and use the pre-record policies when they are invoked. If the function or macro implementation sets policies, the changes automatically propagate up through callers until they reach the closest nested policy stack entry.

We should update the docs in cmake_minimum_required() to drop or soften the note quoted above, or add the missing details about what the limitations are if there are indeed any.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None