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

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.6.0, 6.7
    • Build System: CMake
    • None
    • fcb548878 (dev)

    Description

      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.

      Attachments

        Issue Links

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

          Activity

            People

              qtbuildsystem Qt Build System Team
              thiago Thiago Macieira
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes