ninja: generated resources are regenerated on clean if not present
When the generated file is present clean
runs through smoothly, apart from weird ninja warnings:
ninja: warning: multiple rules generate foo.qrc. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
(reported here)
But if the file wasn’t generated yet or ninja clean
(cmake --build . --target clean
doesn’t exhibit this) is run consecutively, the file is generated and CMake is rerun to regenerate the build files before actually cleaning.
project(cmake-ninja-generated-autogen-clean)
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core)
add_custom_command(OUTPUT foo.qrc
COMMAND ${CMAKE_COMMAND} -E touch foo.qrc
COMMAND echo "oh noes"
)
add_executable(${PROJECT_NAME} foo.qrc)
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS foo.qrc)