D10450: Generate a custom target in kcoreaddons_desktop_to_json

Michael Pyne noreply at phabricator.kde.org
Sat Feb 17 20:51:15 UTC 2018


mpyne added a comment.


  What about this?  I can't change the diff since I didn't create the RR, but this seems to cause the required dependency rules to be added and works for me to build plasma-desktop.  The only real addition is the `add_dependencies` call.  I tried this without the `add_custom_target` dance but CMake complained about the JSON file not being present so it looks like it needs to be a real CMake target to work.
  
    diff --git a/KF5CoreAddonsMacros.cmake b/KF5CoreAddonsMacros.cmake
    index f22817d..c15ab98 100644
    --- a/KF5CoreAddonsMacros.cmake
    +++ b/KF5CoreAddonsMacros.cmake
    @@ -58,13 +58,19 @@ function(kcoreaddons_desktop_to_json target desktop)
           endforeach()
         endif()
     
    +    # Create a virtual target for the generated JSON file and force
    +    # the passed in target and its auto-generated sources to depend upon it
    +    string(RANDOM _target_name_suffix)
    +    set(_json_target "desktop_to_json_${_target_name_suffix}")
    +    add_custom_target(${_json_target})
         add_custom_command(
    -        OUTPUT ${json}
    +        TARGET ${_json_target}
             COMMAND ${command}
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
             DEPENDS ${desktop}
         )
    -    set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${json})
    +    add_dependencies(${target} ${_json_target})
    +    set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${_json_target})
     endfunction()
     
     function(_desktop_to_json_cmake28 desktop json compat)
  
  A resulting Make-based build directory seems to contain the right rules:
  
    CMakeFiles/Makefile2
    6522:kcms/lookandfeel/CMakeFiles/kcm_lookandfeel.dir/all: kcms/lookandfeel/CMakeFiles/desktop_to_json_ChFVC.dir/all
    6597:kcms/lookandfeel/CMakeFiles/kcm_lookandfeel_autogen.dir/all: kcms/lookandfeel/CMakeFiles/desktop_to_json_ChFVC.dir/all

REPOSITORY
  R244 KCoreAddons

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

To: tcberner, #freebsd, mpyne, bshah, dfaure, rakuco
Cc: rikmills, rakuco, kfunk, adridg, kossebau, #frameworks, michaelh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180217/086d8c05/attachment.html>


More information about the Kde-frameworks-devel mailing list