D22698: Support passing target to ki18n_wrap_ui macro

Daan De Meyer noreply at phabricator.kde.org
Mon Aug 5 18:54:08 BST 2019


daandemeyer added a comment.


  To give an example of how the addition would improve KDE CMake build scripts, let's look at part of Kate's CMake build script.
  
  It currently looks like this:
  
    # collect the needed source files
    set (KATE_LIBRARY_SRCS
       kateappadaptor.cpp
       kateapp.cpp
       kateconfigdialog.cpp
       kateconfigplugindialogpage.cpp
       katedocmanager.cpp
       katefileactions.cpp
       katemainwindow.cpp
       katepluginmanager.cpp
       kateviewmanager.cpp
       kateviewspace.cpp
       katesavemodifieddialog.cpp
       katemwmodonhddialog.cpp
       katecolorschemechooser.cpp
       katequickopenmodel.cpp
       katetabbutton.cpp
       katetabbar.cpp
    
       # session
       session/katesessionsaction.cpp
       session/katesessionmanager.cpp
       session/katesessionmanagedialog.cpp
       session/katesession.cpp
    
       katemdi.cpp
       katerunninginstanceinfo.cpp
       katequickopen.cpp
       katewaiter.h
    )
    
    ki18n_wrap_ui(KATE_LIBRARY_SRCS
        ui/sessionconfigwidget.ui
        session/katesessionmanagedialog.ui
    )
    
    add_library(kdeinit_kate STATIC ${KATE_LIBRARY_SRCS})
  
  If the proposed change is accepted, it could be refactored to the following:
  
    add_library(kdeinit_kate STATIC "")
    
    ki18n_wrap_ui(kdeinit_kate
        ui/sessionconfigwidget.ui
        session/katesessionmanagedialog.ui
    )
    
    target_sources(kdeinit_kate PRIVATE
       kateappadaptor.cpp
       kateapp.cpp
       kateconfigdialog.cpp
       kateconfigplugindialogpage.cpp
       katedocmanager.cpp
       katefileactions.cpp
       katemainwindow.cpp
       katepluginmanager.cpp
       kateviewmanager.cpp
       kateviewspace.cpp
       katesavemodifieddialog.cpp
       katemwmodonhddialog.cpp
       katecolorschemechooser.cpp
       katequickopenmodel.cpp
       katetabbutton.cpp
       katetabbar.cpp
    
       # session
       session/katesessionsaction.cpp
       session/katesessionmanager.cpp
       session/katesessionmanagedialog.cpp
       session/katesession.cpp
    
       katemdi.cpp
       katerunninginstanceinfo.cpp
       katequickopen.cpp
       katewaiter.h
    )
  
  
  
  - We don't need a `SRCS` variable anymore. Instead, generated files are added directly to the library target using the `target_sources` command.
  - The order commands are called in becomes more intuitive. We can call `add_library` first, follow with the `ki18n_wrap_ui` command and end with specifying the long list of source files instead of having to start the script with specifying all source files.

REVISION DETAIL
  https://phabricator.kde.org/D22698

To: daandemeyer, ilic
Cc: ltoscano, alexmerry, turbov, cgiboudeaux, kde-frameworks-devel, LeGast00n, sbergeron, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190805/9800c5e8/attachment.html>


More information about the Kde-frameworks-devel mailing list