cmake_policy ignored in subprojects with cmake_minimum_required < 3.13
I have a project where I want to override the default value of an option in an external subproject. Doing this, I got warnings about CMP0077, which I tried to silence with cmake_policy(SET CMP0077 NEW)
in the CMakeLists.txt of the top project. However, the policy never got set in the subproject and the warning remained. After fiddling around a bit, I realized that if I change cmake_minimum_required of my subproject to 3.13 (it was 2.8.12), the policy setting propagates all the way down. I guess this goes in line with that CMP0077 was introduced in CMake 3.13, but it is very confusing to me.
Is this behaviour intentional or is it a bug?
I can also use set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
which behaves as I expect.
I have attached a small example project that illustrates the problem.test-cmake-policy-propagation.zip