# Setting cmake\_minimum\_required globally or in a shared script

**URL:** https://discourse.cmake.org/t/setting-cmake-minimum-required-globally-or-in-a-shared-script/15235
**Category:** Usage
**Created:** [October 12, 2025, 10:17am UTC](https://discourse.cmake.org/t/setting-cmake-minimum-required-globally-or-in-a-shared-script/15235 "2025-10-12T10:17:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisJaquet](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chrisjaquet/32/304_2.png) [@ChrisJaquet](https://discourse.cmake.org/u/ChrisJaquet)
#### Post date: [October 12, 2025, 10:17am UTC](https://discourse.cmake.org/t/setting-cmake-minimum-required-globally-or-in-a-shared-script/15235/1 "2025-10-12T10:17:17Z")

</div>

We have a set of shared CMake scripts that are used by all of our projects and their dependencies. Up until recently we have done something on the lines of

```cmake
project(MyProject)

include(../SharedCMakeScripts/Common.cmake)
cmake_minimum_required(VERSION ${CMN_CMAKE_MIN_VERSION} FATAL_ERROR)

```

where in `Common.cmake` we have something on the lines of

```cmake
# Required version of CMake
set(CMN_CMAKE_MIN_VERSION 3.22)
cmake_minimum_required(VERSION ${CMN_CMAKE_MIN_VERSION} FATAL_ERROR)

cmake_policy(SET CMP0011 NEW)
...

```

This provides us with a central place to set the minimum version of CMake since all our internal projects use this same `Common.cmake` file which also defines a number of helper macros, functions, etc.

From CMake 3.27 onward we (as expected) get the warning:

```auto
CMake Warning (dev) at CMakeLists.txt:1 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call. Please see the cmake-commands(7) manual for usage documentation of
  both commands.

```

So my question is: is there a recommended way to specify this minimum version of CMake globally? I tried in a toolchain file, but that did not seem to have any effect.

Feel free to point me to documentation or other answers/posts if this has been answered elsewhere. I did a search but it is possible the terms I was searching for were incorrect.
