NCAR / ccpp-framework

Common Community Physics Package (CCPP)
http://www.dtcenter.org/community-code/common-community-physics-package-ccpp/
Other
26 stars 64 forks source link

Update cmake version requirement to fix warnings that _ROOT variables are ignored #610

Closed climbfuji closed 17 hours ago

climbfuji commented 1 week ago

Description

@DusanJovic-NOAA reported this:

When building ufs on Hera (with gnu) I see this ccpp (framework and physics) cmake warnings:


CMake Warning (dev) at FV3/ccpp/framework/CMakeLists.txt:15 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
command to set the policy and suppress this warning.

Environment variable MPI_ROOT is set to:

/scratch2/NCEPDEV/stmp1/role.epic/installs/openmpi/4.1.6_gnu13.3

For compatibility, CMake is ignoring the variable. This warning is for project developers. Use -Wno-dev to suppress it.

> This is the description about CMP0074 policy:

$ cmake --help-policy CMP0074 CMP0074

.. versionadded:: 3.12

find_package() uses <PackageName>_ROOT variables.

In CMake 3.12 and above the find_package(<PackageName>) command now searches prefixes specified by the <PackageName>_ROOT CMake variable and the <PackageName>_ROOT environment variable. Package roots are maintained as a stack so nested calls to all find_* commands inside find modules and config packages also search the roots as prefixes. This policy provides compatibility with projects that have not been updated to avoid using <PackageName>_ROOT variables for other purposes.

The OLD behavior for this policy is to ignore <PackageName>_ROOT variables. The NEW behavior for this policy is to use <PackageName>_ROOT variables.

This policy was introduced in CMake version 3.12. CMake version 3.23.1 warns when the policy is not set and uses OLD behavior. Use the cmake_policy() command to set it to OLD or NEW explicitly.

.. note:: The OLD behavior of a policy is deprecated by definition and may be removed in a future version of CMake.


> In both framework and physics the minimum cmake version is set to be 3.10. That means, for compatibility with older cmake versions, `*_ROOT` variables are ignored. To silence this warning we need to either set the policy to `NEW` or update minimum cmake version to `>= 3.12`

## Solution

Current cmake versions used on the tier-1 platforms are somewhere around 3.20 (provided by the operating system or as default modules) or closer to 3.30 (spack-stack built). We can therefore safely increase the minimum version required to 3.18, for example.

## Alternatives (optional)

Do nothing - no good.

## Related to (optional)

https://github.com/NCAR/ccpp-physics/issues/1100