Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-36768

Using absolute paths in output_function of QMAKE_EXTRA_COMPILERS generates broken Makefile

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P4: Low P4: Low
    • 5.12.1
    • 4.8.5, 5.2.1
    • Build tools: qmake
    • None
    • Arch Linux x64, make 4.0
    • 3f2786e3226ac8b25188fe1b1e6de802996f6720

      When using output_function of QMAKE_EXTRA_COMPILERS with absolute paths the Makefile throws an error.

      make: *** No rule to make target '../build_qm_test/translations/qm_test_de.qm', needed by 'libqm_test.so.1.0.0'.  Stop.

      The problem is, that the EXTRA_COMPILER is added as dependency to the TARGET with a relative path.
      But the rule for the EXTRA_COMPILER uses the absolute path.

      The following project file reproduces the problem.
      Just run

      lupdate *.pro
      qmake
      make
      

      If you remove the line marked with "1", which causes a relative path to be used, no error is thrown and the translations are created.

      Using "output" (#2) also works.

      TEMPLATE = lib
      
      defineReplace(targetPath) {
      	win32:1 ~= s|\\\\|/|g
      	return($$1)
      }
      LRELEASE = $$targetPath($$[QT_INSTALL_BINS]/lrelease)
      TRANSLATIONS = $${TARGET}_de.ts $${TARGET}_en.ts
      
      buildDir = ../build_qm_test/
      # 1
      buildDir = $$absolute_path($$buildDir)/
      message(buildDir: $${buildDir})
      
      defineReplace(generateQmFilename) {
      	qmFile = $$basename(1)
      	qmFile = $$replace(qmFile, "\\.ts", ".qm")
      	return($${buildDir}translations/$${qmFile})
      }
      
      updateqm.input = TRANSLATIONS
      # 2
      #updateqm.output = $${buildDir}translations/${QMAKE_FILE_BASE}.qm
      updateqm.output_function = generateQmFilename
      isEmpty(vcproj):updateqm.variable_out = PRE_TARGETDEPS
      updateqm.commands = $$LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
      updateqm.name = LRELEASE ${QMAKE_FILE_IN}
      updateqm.CONFIG += no_link
      QMAKE_EXTRA_COMPILERS += updateqm
      

      I wanted to change the name of the generated .qm files, because the project is used with some modifications under different names. Or is there another way to achieve this.

        For Gerrit Dashboard: QTBUG-36768
        # Subject Branch Project Status CR V

            buddenha Oswald Buddenhagen
            mkrems Marcel Krems
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes