Skip to content

CMake policy CMP0091 should be upgraded to new form #63286

@mstorsjo

Description

@mstorsjo

CC @zmodem @rnk @glandium

After upgrading the minimum CMake version to 3.20, the CMake policy CMP0091 https://cmake.org/cmake/help/latest/policy/CMP0091.html changed to the new form, which broke a couple build scenarios, as mentioned in #62719. It also broke the LLVM custom parameters for setting what CRT to link against, as described in #62739.

This was temporarily remedied by switching the policy CMP0091 back to the old form in 7d47dac / https://reviews.llvm.org/D150688 (and after a revert, when relanded in cbaa359).

Switching the policy to old form is a temporary workaround, as newer CMake warns:

CMake Deprecation Warning at /home/martin/code/llvm-project/cmake/Modules/CMakePolicy.cmake:6 (cmake_policy):
  The OLD behavior for policy CMP0091 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

In order to switch to the new policy, the root cause of the issues in #62719 need to be fixed; compiler-rt has some custom code for selecting CRT, which doesn't work in the new mode. A pointer to this is https://github.com/llvm/llvm-project/blob/llvmorg-16.0.3/compiler-rt/CMakeLists.txt#L398. Also, the LLVM custom options for choosing the CRT to link, in https://github.com/llvm/llvm-project/blob/llvmorg-16.0.3/llvm/cmake/modules/ChooseMSVCCRT.cmake, need to be updated to use the new CMake mechanisms for selecting CRT, instead of meddling directly in the CMAKE_${lang}_FLAGS_${build} variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cmakeBuild system in general and CMake in particularplatform:windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions