cmake_policy(SET CMP0077 NEW) not working correctly ?
Use case : including the poco libraries via FetchContent into my build tree. And I want the poco libraries to be build in a static way. The policy does not work and keeps giving warnings, I can only make it to work via : set(POCO_STATIC ON CACHE BOOL "")
.
I stripped the setup down to the following to reproduce :
MYDIR
|
+ CMakeLists.txt (1)
|
+ poco
|
+ CMakeLists.txt (2)
The content of (1) :
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
project(dummy)
cmake_policy(SET CMP0077 NEW) # this does not seem to help at all ????
#set(POCO_STATIC ON CACHE BOOL "")
set(POCO_STATIC ON)
add_subdirectory(poco)
and the content of (2) :
cmake_minimum_required(VERSION 3.2.0)
project(Poco)
option(POCO_STATIC
"Set to OFF|ON (default is OFF) to control build of POCO as STATIC library" OFF)
message(STATUS "${POCO_STATIC}")
When invoking as : cmake -D CMAKE_BUILD_TYPE=Release -H. -Bbuild
==>
CMake Warning (dev) at poco/CMakeLists.txt:5 (option):
Policy CMP0077 is not set: option() honors normal variables. Run "cmake
--help-policy CMP0077" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
For compatibility with older versions of CMake, option is clearing the
normal variable 'POCO_STATIC'.
This warning is for project developers. Use -Wno-dev to suppress it.
-- OFF
So we see we get the warning, and it is still OFF.
According to : https://cmake.org/cmake/help/v3.16/policy/CMP0077.html, it seems it is intended for the use case I want to carry out.
Is this indeed a bug, or am I doing something wrong ?
I can make it work, by setting in (2) the minimum required also to 3.15. But that is the problem, I am not in charge of that CMakeLists.txt, and I shouldn't be, right.