I've been looking for the way to do this in CMake. I find pages that were written years ago saying that the capability to add custom build rules is intentionally disabled in CMake, for reasons unexplained, with no explanation how to enable it. It looks like the way to do it is:
1. List all .ts files in the source directory.
2. Run the list through sed, changing the source directory to the build directory and the extension to .qm .
3. Run the CMake add_custom_command command on each .qm file (whether it exists or not), telling it that it can be made by running lrelease on the corresponding .ts file.
As to updating the .ts files, they are source files which have to be manually edited by translators, so they can't be updated by CMake. Use a shell script that just does "lupdate *.cpp -ts *.ts".
Bookmarks