OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

Avoid rebuilding 100+ OpenImageIO files when rerunning CMake due to rewriting the fmt proxy headers (external fmt case)

Open Willem871 opened this issue 6 months ago • 15 comments

Description

OpenImageIO uses some proxy fmt headers, created at CMake time, that have a different content depending on using an external or the embedded fmt library. In case of using an external fmt (i.e., OIIO_USING_FMT_LOCAL and INTERNALIZE_FMT are OFF), the current CMake code uses "file (WRITE)" to write the fmt proxy headers, which always overwrites existing files. Hence, when rerunning CMake the timestamp of those headers is always updated, triggering a rebuild of a whole bunch of OpenImageIO files.

To fix this I propose to use configure_file, which is also recommended by the CMake documentation of file(WRITE), see https://cmake.org/cmake/help/latest/command/file.html. This will only overwrite the output file when the content of the input file has changed.

Tests

Not applicable, this is just a build improvement.

Checklist:

  • [x] I have read the contribution guidelines.
  • [x] ~~I have updated the documentation, if applicable.~~ Not applicable
  • [x] ~~I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).~~ Not applicable, build stuff.
  • [x] ~~If I added or modified a C++ API call, I have also amended the corresponding Python bindings (and if altering ImageBufAlgo functions, also exposed the new functionality as oiiotool options).~~ Not applicable, since CMake
  • [x] My code follows the prevailing code style of this project. If I haven't already run clang-format before submitting, I definitely will look at the CI test that runs clang-format and fix anything that it highlights as being nonconforming.

Willem871 avatar Dec 21 '23 09:12 Willem871