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

Make qt_config_compile_test() delay compiling its test until the result is needed

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.9.0 FF
    • 6.6.0, 6.7
    • Build System: CMake
    • None
    • fcb548878 (dev), 605913f9d (dev), b2b7f1896 (dev)

      We have a lot of tests defined in our configure.cmake files that aren't always applicable. For example:

      src/gui/configure.cmake
      qt_config_compile_test(integrityfb
          LABEL "INTEGRITY framebuffer"
          CODE
      "#include <device/fbdriver.h>
      
      int main(void)
      {
          /* BEGIN TEST: */
      FBDriver *driver = 0;
          /* END TEST: */
          return 0;
      }
      ")
      ...
      qt_feature("integrityfb" PRIVATE
          SECTION "Platform plugins"
          LABEL "INTEGRITY framebuffer"
          CONDITION INTEGRITY AND TEST_integrityfb
      )
      

      The integrityfb test is conditional on INTEGRITY being true, which it will only be on Integrity systems. However, the test is compiled everywhere and contributes 360 ms of runtime for CMake.

      We could reorganise the configure.cmake files with if for some conditions that will be set before the file is parsed (such as the OS, as in this case), but it won't work for feature-dependency tests, like:

      src/corelib/configure.cmake
      qt_feature("poll_ppoll" PRIVATE
          LABEL "Native ppoll()"
          CONDITION NOT WASM AND TEST_ppoll
          EMIT_IF NOT WIN32
      )
      qt_feature("poll_pollts" PRIVATE
          LABEL "Native pollts()"
          CONDITION NOT QT_FEATURE_poll_ppoll AND TEST_pollts
          EMIT_IF NOT WIN32
      )
      qt_feature("poll_poll" PRIVATE
          LABEL "Native poll()"
          CONDITION NOT QT_FEATURE_poll_ppoll AND NOT QT_FEATURE_poll_pollts AND TEST_poll
          EMIT_IF NOT WIN32
      )
      

      The poll_pollts and poll_poll} tests don't need to be executed if {{poll_ppoll has already succeeded. And we can't use if here because the {[QT_FEATURE_}} variables won't be set yet.

      I believe this is a regression from the qmake configure system.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jbornema Joerg Bornemann
            thiago Thiago Macieira
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes