-1

I'm using CMake for a project, and generating some configuration .h files with a configure_file() command. This works well enough, but - if I make clean, the generated file is not deleted - nor is it overwritten when I invoke cmake again with different parameters (or ccmake and so on).

Why is this the case, and how can I force re-generation of configure_file output files - when necessary / always?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • `make clean` is intended to remove **build** artifacts but not **configuration** ones. `configure_file` creates the file on *configuration* stage, so that file shouldn't be cleaned. There is `make distclean` in Autotools which removes the files created on configuration stage. CMake neither provides this target nor, as far as I know, creates its own target for that purpose. With *out-of-source* build removing build directory is sufficient to clean up configuration. – Tsyvarev Jun 24 '19 at 07:32
  • Actually, there is a little reason to remove the file, created by `configure_file`, for the purpose to regenerate it. If `cmake` is called, it **always** recomputes content of the file, and rewrites the file if its current content differs from the computed one. – Tsyvarev Jun 24 '19 at 07:34
  • @Tsyvarev: About your second comment - that's not what I'm seeing. – einpoklum Jun 24 '19 at 08:48

1 Answers1

0

It seems this may happen if the files are generated under the source folder rather than under the build folder. I think CMake treated the (generated) files it found as source files - or at least, not build files (see @Tsyvarev's comment), so they must not be deleted/altered.

einpoklum
  • 118,144
  • 57
  • 340
  • 684