Dependencies for windows resource (.rc) files are not detected correctly
CMake (at least with the Ninja back-end) scans only for #include-style dependencies in .rc files. When a binary file (such as an application icon) is compiled into a .res file, the build system doesn't know this, and doesn't regenerate the resource file when the dependency is updated.
Trivial example below:
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(example)
add_executable(example example.c example.rc)
example.c
int main(){return 0;}
example.rc
1 ICON DISCARDABLE "example.ico"
example.ico - use any icon file
How to reproduce:
$ cmake -G Ninja ..
[...]
-- Build files have been written to: C:/Users/ld/resourcebug/build
ld@w10vm VC ~/resourcebug/build
$ ninja
[1/3] Building C object CMakeFiles\example.dir\example.c.obj
[2/3] Building RC object CMakeFiles\example.dir\example.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.
[3/3] Linking C executable example.exe
ld@w10vm VC ~/resourcebug/build
$ touch ../example.ico
ld@w10vm VC ~/resourcebug/build
$ ninja
ninja: no work to do.
Expected result: the executable is rebuilt with the updated icon