CMP0143 seemingly not working, how to debug?

Hi there, a colleague of mine was upgrading our CMake version from 3.24.2 to 3.31.6 (along with all the policy changes) and we stumbled upon some strange behaviour with the USE_FOLDERS property which should now default to ON.

We have been explicitly setting: set_property(GLOBAL PROPERTY USE_FOLDERS ON) before and thought we could remove those calls now with the new policies, but the generated VS solutions didn’t have any folders in them.

I believe we checked that: USE_FOLDERS is not set at the end of the top-level CMakeLists.txt, and that the CMP0143 policy value is NEW.

Putting an explicit call to set_property at the end fixes this so we’re probably not going to spend much more time debugging it, but wanted to ask around what that would entail.

It will only default to ON if you’ve updated your cmake_minimum_required() at the top of your project to include CMake 3.26 or later. Without that, you’re still getting OLD policy settings for all policies in CMake versions later than whatever your cmake_minimum_required() is set to.

Yes actually we have that, i.e. cmake_minimum_required(VERSION 3.31.6) as the very first statement in the top level CMakeLists.txt. It is not being called in a function either.

Sounds like a bug then. If you’ve got a small, complete project that demonstrates the behavior, please open a new issue for it: https://gitlab.kitware.com/cmake/cmake/-/issues/new