configure_file from subdirectory: removal of generated config file does not trigger regeneration on make
Basically the same problem as described in here: https://public.kitware.com/Bug/print_bug_page.php?bug_id=13582 (#13582 (closed)). But now configure_file
is called from a subdirectory.
The previously reported bug has been fixed, I confirmed that with the example code that was provided. When configure_file
is called from the top-level CMakeLists.txt
generated files are regenerated on make
if they have been deleted in between the cmake
and the make
invocation.
However, if the call to configure_file
is in a sub-project, included into the top-level CMakeLists.txt
via add_subdirectory
the generated file is not regenerated on make
when it has been deleted. Please find my updated example attached for you to reproduce the problem.
cmake-config-regeneration-bug_subdir.zip
Steps to reproduce:
Go to the unzipped folder in the console and execute the following commands:
mkdir build && cd build
cmake ..
rm ../subdir/Config.h
make
Result:
With the command cmake ..
the Config.h
file is generated. Then after it is removed and make
is issued it is not generated again.
The compiler throws an error: fatal error: Config.h: No such file or directory
Desired outcome:
When make
is called, the Config.h
file should be regenerated if it has changed since the last build. That would provide the same behaviour as when configure_file
is called from the top-level CMakeLists.txt
.