Bug 460245 - ki18n_install(po) slows down each build, even if nothing has changed
Summary: ki18n_install(po) slows down each build, even if nothing has changed
Status: REPORTED
Alias: None
Product: frameworks-ki18n
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.98.0
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Chusslove Illich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-11 14:59 UTC by Igor Kushnir
Modified: 2023-05-07 06:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kushnir 2022-10-11 14:59:19 UTC
SUMMARY
Building projects that have the `ki18n_install(po)` line in CMakeLists.txt, such as KDevelop, kio-extras and ki18n itself, always produces output like this, even if nothing has changed:
[2/2] Generating ts...
[2/2] Generating mo...

Commenting out the `ki18n_install(po)` line works the issue around. A nothing-changed KDevelop build takes 8 seconds with the `ki18n_install(po)` line and less than a second without it:
$ ninja
ninja: no work to do.

Debug output when the `ki18n_install(po)` line is present:
$ ninja -d explain
ninja explain: output CMakeFiles/pofiles-1ce71fd1ec78d5566f158140586603a7 doesn't exist
ninja explain: CMakeFiles/pofiles-1ce71fd1ec78d5566f158140586603a7 is dirty
ninja explain: pofiles-1ce71fd1ec78d5566f158140586603a7 is dirty
ninja explain: output CMakeFiles/tsfiles-1ce71fd1ec78d5566f158140586603a7 doesn't exist
ninja explain: CMakeFiles/tsfiles-1ce71fd1ec78d5566f158140586603a7 is dirty
ninja explain: tsfiles-1ce71fd1ec78d5566f158140586603a7 is dirty

The same issue occurs when the Makefile generator is used:
$ make
[  1%] Generating mo...
[  1%] Built target pofiles-1ce71fd1ec78d5566f158140586603a7
[  2%] Generating ts...

SOFTWARE/OS VERSIONS
Manjaro GNU/Linux, Xfce, X11
KDE Frameworks Version: 5.98
Qt Version: 5.15.6+kde

ADDITIONAL INFORMATION
See also https://invent.kde.org/kdevelop/kdevelop/-/issues/13
Comment 1 Milian Wolff 2022-10-13 20:12:41 UTC
the issue is that it's using `add_custom_target` which is always dirty.

in practice, `add_custom_target` should basically never be used imo - it would be much better to rewrite this to leverage `add_custom_command` instead, such that dependencies can be properly tracked. but that would require us to pass a target along to the macro that can be associated with the command - otherwise it would never be build.

a pity that one cannot use `ALL` for `add_custom_command` :(

very nasty, I wonder why no-one else complained about this yet :)
Comment 2 Igor Kushnir 2022-10-14 09:33:06 UTC
(In reply to Milian Wolff from comment #1)
> very nasty, I wonder why no-one else complained about this yet :)
Maybe because the po files were committed to the main repositories only about two weeks ago. And the build slowdown of most projects is much less than 8 seconds.
Comment 3 Milian Wolff 2023-03-06 18:46:52 UTC
https://discourse.cmake.org/t/feature-request-add-custom-command-all/7609

Let's see what the cmake wizards have to say to this
Comment 4 Igor Kushnir 2023-05-07 06:19:52 UTC
(In reply to Milian Wolff from comment #3)
> https://discourse.cmake.org/t/feature-request-add-custom-command-all/7609
> 
> Let's see what the cmake wizards have to say to this
The proposed solution is:
> add_custom_command(OUTPUT file.txt COMMAND ${CMAKE_COMMAND} -E touch file.txt)
> add_custom_target(tgt ALL DEPENDS file.txt)
Questions:
1. Is it possible/how to enumerate all OUTPUT files in the CMake command?
2. Would the translations be updated after a *.po file is modified?