/usr/lib/x86_64-linux-gnu/cmake/KF5Package/KF5PackageMacros.cmake is in libkf5package-dev 5.44.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | find_package(ECM 1.6.0 CONFIG REQUIRED)
include(${ECM_KDE_MODULE_DIR}/KDEInstallDirs.cmake)
set(KPACKAGE_RELATIVE_DATA_INSTALL_DIR "kpackage")
# kpackage_install_package(path componentname [root] [install_dir])
#
# Installs a package to the system path
# @arg path The source path to install from, location of metadata.desktop
# @arg componentname The plugin name of the component, corresponding to the
# X-KDE-PluginInfo-Name key in metadata.desktop
# @arg root The subdirectory to install to, default: packages
# @arg install_dir the path where to install packages,
# such as myapp, that would go under prefix/share/myapp:
# default ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR}
#
# Examples:
# kpackage_install_package(mywidget org.kde.plasma.mywidget plasmoids) # installs an applet
# kpackage_install_package(declarativetoolbox org.kde.toolbox packages) # installs a generic package
# kpackage_install_package(declarativetoolbox org.kde.toolbox) # installs a generic package
#
set(kpackagedir ${CMAKE_CURRENT_LIST_DIR})
function(kpackage_install_package dir component)
message(AUTHOR_WARNING "Deprecated: use kpackage_install_bundled_package")
set(root ${ARGV2})
set(install_dir ${ARGV3})
if(NOT root)
set(root packages)
endif()
if(NOT install_dir)
set(install_dir ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR})
endif()
install(DIRECTORY ${dir}/ DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component}
PATTERN .svn EXCLUDE
PATTERN *.qmlc EXCLUDE
PATTERN CMakeLists.txt EXCLUDE
PATTERN Messages.sh EXCLUDE
PATTERN dummydata EXCLUDE)
set(metadatajson)
if(NOT EXISTS ${component}-${root}-metadata.json AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop)
set(GENERATED_METADATA "${CMAKE_CURRENT_BINARY_DIR}/${component}-${root}-metadata.json")
add_custom_command(OUTPUT ${GENERATED_METADATA}
COMMAND KF5::desktoptojson -i ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop -o ${GENERATED_METADATA})
add_custom_target(${component}-${root}-metadata-json ALL DEPENDS ${GENERATED_METADATA})
install(FILES ${GENERATED_METADATA} DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component} RENAME metadata.json)
set(metadatajson ${GENERATED_METADATA})
endif()
get_target_property(kpackagetool_cmd KF5::kpackagetool5 LOCATION)
if (${component} MATCHES "^.+\\..+\\.") #we make sure there's at least 2 dots
set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml")
execute_process(
COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/${dir} --appstream-metainfo-output ${APPDATAFILE}
ERROR_VARIABLE appstreamerror
RESULT_VARIABLE result)
if (NOT result EQUAL 0)
message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}")
else()
if(appstreamerror)
message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}")
endif()
# OPTIONAL because desktop files can be NoDisplay so they render no XML.
install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR} OPTIONAL)
endif()
else()
message(WARNING "KPackage components should be specified in reverse domain notation. Appstream information won't be generated for ${component}.")
endif()
set(newentry "${kpackagetool_cmd} --generate-index -g -p ${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_DATADIR}/${install_dir}/${root}\n")
get_directory_property(currentindex kpackageindex)
string(FIND "${currentindex}" "${newentry}" alreadyin)
if (alreadyin LESS 0)
set(regenerateindex "${currentindex}${newentry}")
set_directory_properties(PROPERTIES kpackageindex "${regenerateindex}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/regenerateindex.sh ${regenerateindex})
endif()
endfunction()
#use this version instead: it compresses the contents directory
#into a binary rcc file
function(kpackage_install_bundled_package dir component)
set(root ${ARGV2})
set(install_dir ${ARGV3})
if(NOT root)
set(root packages)
endif()
if(NOT install_dir)
set(install_dir ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR})
endif()
set(metadatajson)
if(NOT EXISTS ${component}-${root}-metadata.json AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop)
set(GENERATED_METADATA "${CMAKE_CURRENT_BINARY_DIR}/${component}-${root}-metadata.json")
add_custom_command(OUTPUT ${GENERATED_METADATA}
COMMAND KF5::desktoptojson -i ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop -o ${GENERATED_METADATA})
add_custom_target(${component}-${root}-metadata-json ALL DEPENDS ${GENERATED_METADATA})
install(FILES ${GENERATED_METADATA} DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component} RENAME metadata.json)
set(metadatajson ${GENERATED_METADATA})
endif()
get_target_property(kpackagetool_cmd KF5::kpackagetool5 LOCATION)
if (${component} MATCHES "^.+\\..+\\.") #we make sure there's at least 2 dots
set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml")
execute_process(
COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/${dir} --appstream-metainfo-output ${APPDATAFILE}
ERROR_VARIABLE appstreamerror
RESULT_VARIABLE result)
if (NOT result EQUAL 0)
message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}")
else()
if(appstreamerror)
message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}")
endif()
# OPTIONAL because desktop files can be NoDisplay so they render no XML.
install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR} OPTIONAL)
endif()
else()
message(WARNING "KPackage components should be specified in reverse domain notation. Appstream information won't be generated for ${component}.")
endif()
set(newentry "${kpackagetool_cmd} --generate-index -g -p ${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_DATADIR}/${install_dir}/${root}\n")
get_directory_property(currentindex kpackageindex)
string(FIND "${currentindex}" "${newentry}" alreadyin)
if (alreadyin LESS 0)
set(regenerateindex "${currentindex}${newentry}")
set_directory_properties(PROPERTIES kpackageindex "${regenerateindex}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/regenerateindex.sh ${regenerateindex})
endif()
set(kpkgqrc "${CMAKE_CURRENT_BINARY_DIR}/${component}.qrc")
set(kpkgrcc "${CMAKE_CURRENT_BINARY_DIR}/${component}.rcc")
add_custom_command(OUTPUT ${kpkgqrc} ${kpkgrcc}
DEPENDS ${metadatajson}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir}
COMMAND cmake "-Dmetadatajson=${metadatajson}" -Droot=${root} -Dinstall_dir=${install_dir} -DBINARYDIR=${CMAKE_CURRENT_BINARY_DIR} -DDIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/${dir}" -DOUTPUTFILE=${kpkgqrc} -DCOMPONENT=${component} -P ${kpackagedir}/qrc.cmake
COMMAND Qt5::rcc ${kpkgqrc} --binary -o ${kpkgrcc}
)
add_custom_target(${component}-${root}-qrc ALL DEPENDS ${kpkgqrc})
install(FILES ${kpkgrcc} DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component}/ RENAME contents.rcc)
endfunction()
|