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

Add CMake feature for a function to be called when a target is "closed" (scope finalizers)

    XMLWordPrintable

Details

    Description

      This would provide cleaner CMake API inside the Qt CMake files.

      For example for qml, without this feature, you could have a hypothetical API as follows.

      add_qml_module(Foo)
      qml_target_sources(Foo a.qml)
      if(APPLE)
        qml_target_sources(Foo b.qml)
      endif()
      
      more qml_target_source calls .....
      
      qml_run_quick_compiler(Foo)
      

      qml_run_quick_compiler needs to be called manually by a user after all qml_target_sources have been called.

      With proposed feature, we could have a cleaner API where the user does not have to specify the qml_run_quick_compiler call, it would be called automatically by CMake.

      add_qml_module(Foo)
      qml_target_sources(Foo a.qml)
      if(APPLE)
        qml_target_sources(Foo b.qml)
      endif()
      
      more qml_target_source calls .....
      

      and inside add_qml_module you would have something like:

      function(qml_run_quick_compiler target)
      ...
      set_property(TARGET ${target} PROPERTY CALL_ON_TARGET_FINALIZE "qml_run_quick_compiler")
      ...
      endfunction()
      

      Thus the user can't accidentally forget to call qml_run_quick_compiler(), CMake would do it for them.

      Upstream issue https://gitlab.kitware.com/cmake/cmake/issues/19575

      Attachments

        Issue Links

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

          Activity

            People

              alexandru.croitor Alexandru Croitor
              alexandru.croitor Alexandru Croitor
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes