Skip to content

The "cmake/CMakeLists.txt -> CMakeLists.txt" redirection deactivates some policies silently. #12263

@jtattermusch

Description

@jtattermusch

The "cmake/CMakeLists.txt" is now deprecated, but there are some hidden problems with how it's forwarding to /CMakeLists.txt (in the repo root).

I found that some cmake policies get silently deactivated if one uses cmake/CMakeLists.txt

E.g. here:

if(POLICY CMP0091)

Since CMP0091 needs to be set before languages are initialized, but

project(protobuf C CXX)
is reached first, the policy won't be active (which is quite counterintuitive)
and settings made here
if (protobuf_MSVC_STATIC_RUNTIME)
will be overridden by e.g. /MD still being present in CMAKE_CXX_FLAGS_*

(at least this is my interpretation of what happens, but I've observed /MD flag being present when it should not).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions