From 8542e6311c5da5c2e653cbb599d2043e66a1f95e Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 23 Jul 2019 14:08:16 +0200 Subject: [PATCH] Added macro to install a declarative plugin --- declarativeplugin/CMakeLists.txt | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/declarativeplugin/CMakeLists.txt b/declarativeplugin/CMakeLists.txt index 570a6ed68..fd639d13b 100644 --- a/declarativeplugin/CMakeLists.txt +++ b/declarativeplugin/CMakeLists.txt @@ -17,15 +17,25 @@ target_link_libraries(kdeconnectdeclarativeplugin kdeconnectinterfaces ) -install(TARGETS kdeconnectdeclarativeplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kdeconnect) -install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kdeconnect) -# So qml apps using this plugin can be run from build/bin directory -add_custom_target(copy_to_build_dir_bin) -add_custom_command(TARGET copy_to_build_dir_bin POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_BINARY_DIR}/bin/org/kde/kdeconnect/) -add_dependencies(kdeconnectdeclarativeplugin copy_to_build_dir_bin) -set_target_properties(kdeconnectdeclarativeplugin - PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/org/kde/kdeconnect/ -) +## +# Installs a QML declarative plugin and its qmldir file +# +function(install_qml_plugin plugin_name qml_install_dir_path) + + install(TARGETS ${plugin_name} DESTINATION ${QML_INSTALL_DIR}/${qml_install_dir_path}) + install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/${qml_install_dir_path}) + + # So qml apps using this plugin can be run from build/bin directory + add_custom_target(copy_to_build_dir_bin) + add_custom_command(TARGET copy_to_build_dir_bin POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_BINARY_DIR}/bin/${qml_install_dir_path}) + add_dependencies(${plugin_name} copy_to_build_dir_bin) + set_target_properties(${plugin_name} + PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${qml_install_dir_path} + ) +endfunction() + +install_qml_plugin(kdeconnectdeclarativeplugin "org/kde/kdeconnect") +