[regression 3.11] AUTORCC results in a CMP0058 warning when advertising a minimum version lower than CMake 3.3
Starting with CMake 3.11, a project that has minimum CMake version 3.2 or earlier (but not CMake 3.3) using AUTORCC will complain:
CMake Warning (dev):
Policy CMP0058 is not set: Ninja requires custom command byproducts to be
explicit. Run "cmake --help-policy CMP0058" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
This project specifies custom command DEPENDS on files in the build tree
that are not specified as the OUTPUT or BYPRODUCTS of any
add_custom_command or add_custom_target:
CMakeFiles/ExampleOutput_autogen.dir/RCCexampleInfo.cmake
For compatibility with versions of CMake that did not have the BYPRODUCTS
option, CMake is generating phony rules for such files to convince 'ninja'
to build.
Project authors should add the missing BYPRODUCTS or OUTPUT options to the
custom commands that produce these files.
Additionally, said phony target is indeed visible in the build.ninja file (which is not present when using a larger minimum version).
This was bisected to v3.10.2-1009-ga8ee7406 (merged via !1735 (merged), authored by @sebholt).
To reproduce, take the following four files and simply build with cmake -GNinja
.
CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
project(CMakeQtExample)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(CMAKE_AUTORCC ON)
add_executable(ExampleOutput main.cpp example.qrc)
target_link_libraries(ExampleOutput Qt5::Widgets)
main.cpp
#include <QApplication>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
Q_INIT_RESOURCE(example);
return app.exec();
}
example.qrc
<RCC>
<qresource prefix="Example">
<file>Square.ico</file>
</qresource>
</RCC>
Square.ico is just a picture file.