From: Gerhard Sittig Date: Sat, 22 Apr 2023 07:28:12 +0000 (+0200) Subject: cmake: only optionally modify in-source .ts files (Qt lupdate) X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=3903edbd71789f8af1c3b133b5702bd1d66f9242 cmake: only optionally modify in-source .ts files (Qt lupdate) The creation of .qm output files from .ts input data undoubtedly needs to be an unconditional part of the build process. The modification of .ts source files in contrast needs to remain an intentional activity during development. The mere act of compiling sources to binaries shall never modify the source tree. Move the lupdate(1) invocation out of the default build process, while lrelease(1) remains in place. Ideally we could have a "make ts-update" target for developers to invoke as needed. But that'd be more involved since the qt5_create_translation() cmake routine is involved, which needs to be passed variables content that is only available at configure time. A future implementation could investigate the add_custom_target() approach. This commit introduces the ENABLE_TS_UPDATE cmake option to quickly address the issue. How to reproduce: $ cd $SRC $ cmake --build $OUT $ git status -s $ cmake -DENABLE_TS_UPDATE=ON $OUT $ cmake --build $OUT $ git status -s This commit also happens to bring build steps in closer promixity, while making development iterations stand out more perceivably. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ab0f72d..08d0ded5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ option(ENABLE_DECODE "Build with libsigrokdecode" TRUE) option(ENABLE_FLOW "Build with libsigrokflow" FALSE) option(ENABLE_TESTS "Enable unit tests" FALSE) option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE) +option(ENABLE_TS_UPDATE "Update .ts source files (Qt l10n)" FALSE) if(WIN32) # On Windows/MinGW we need to statically link to libraries. @@ -528,14 +529,16 @@ endif () if(Qt5_FOUND) qt5_add_translation(QM_FILES ${TS_FILES}) - qt5_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES}) - qt5_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc) + if (ENABLE_TS_UPDATE) + qt5_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES}) + endif () else() qt6_add_translation(QM_FILES ${TS_FILES}) - qt6_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES}) - qt6_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc) + if (ENABLE_TS_UPDATE) + qt6_create_translation(QM_FILES ${pulseview_SOURCES} ${TS_FILES}) + endif () endif() #===============================================================================