Warning, /frameworks/kpackage/KF5PackageMacros.cmake is written in an unsupported language. File is not indexed.
0001 # To not mess up the ECM_FIND_VERSION we only include ECM if the required variables are not set 0002 if (NOT KDE_INSTALL_DATADIR OR NOT KDE_INSTALL_METAINFODIR) 0003 find_package(ECM 5.83.0 CONFIG REQUIRED) 0004 include(${ECM_KDE_MODULE_DIR}/KDEInstallDirs.cmake) 0005 endif() 0006 set(KPACKAGE_RELATIVE_DATA_INSTALL_DIR "kpackage") 0007 0008 # kpackage_install_package(path componentname [root] [install_dir]) 0009 # 0010 # Installs a package to the system path 0011 # @arg path The source path to install from, location of metadata.desktop 0012 # @arg componentname The plugin name of the component, corresponding to the 0013 # X-KDE-PluginInfo-Name key in metadata.desktop 0014 # @arg root The subdirectory to install to, default: packages 0015 # @arg install_dir the path where to install packages, 0016 # such as myapp, that would go under prefix/share/myapp: 0017 # default ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR} 0018 # 0019 # Examples: 0020 # kpackage_install_package(mywidget org.kde.plasma.mywidget plasmoids) # installs an applet 0021 # kpackage_install_package(declarativetoolbox org.kde.toolbox packages) # installs a generic package 0022 # kpackage_install_package(declarativetoolbox org.kde.toolbox) # installs a generic package 0023 # 0024 0025 set(kpackagedir ${CMAKE_CURRENT_LIST_DIR}) 0026 function(kpackage_install_package dir component) 0027 set(root ${ARGV2}) 0028 set(install_dir ${ARGV3}) 0029 if(NOT root) 0030 set(root packages) 0031 endif() 0032 if(NOT install_dir) 0033 set(install_dir ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR}) 0034 endif() 0035 0036 install(DIRECTORY ${dir}/ DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component} 0037 PATTERN .svn EXCLUDE 0038 PATTERN *.qmlc EXCLUDE 0039 PATTERN CMakeLists.txt EXCLUDE 0040 PATTERN Messages.sh EXCLUDE 0041 PATTERN dummydata EXCLUDE) 0042 0043 set(metadatajson) 0044 set(ORIGINAL_METADATA "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop") 0045 if(NOT EXISTS ${component}-${root}-metadata.json AND EXISTS ${ORIGINAL_METADATA}) 0046 message(WARNING "Providing metadata with .desktop files is deprecated. Please run \"desktoptojson -i ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop\" to convert the file to json and remove the desktop file") 0047 set(GENERATED_METADATA "${CMAKE_CURRENT_BINARY_DIR}/${component}-${root}-metadata.json") 0048 add_custom_target(${component}-${root}-metadata-json ALL DEPENDS ${GENERATED_METADATA}) 0049 kcoreaddons_desktop_to_json(${component}-${root}-metadata-json ${ORIGINAL_METADATA} 0050 OUTPUT_FILE ${GENERATED_METADATA}) 0051 install(FILES ${GENERATED_METADATA} DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component} RENAME metadata.json) 0052 set(metadatajson ${GENERATED_METADATA}) 0053 elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.json") 0054 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.json" DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component}) 0055 endif() 0056 0057 get_target_property(kpackagetool_cmd KF5::kpackagetool5 LOCATION) 0058 if (${component} MATCHES "^.+\\..+\\.") #we make sure there's at least 2 dots 0059 set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml") 0060 0061 execute_process( 0062 COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/${dir} --appstream-metainfo-output ${APPDATAFILE} 0063 ERROR_VARIABLE appstreamerror 0064 RESULT_VARIABLE result) 0065 if (NOT result EQUAL 0) 0066 message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}") 0067 else() 0068 if(appstreamerror) 0069 message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}") 0070 endif() 0071 0072 # OPTIONAL because desktop files can be NoDisplay so they render no XML. 0073 install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR} OPTIONAL) 0074 endif() 0075 else() 0076 message(DEBUG "KPackage components should be specified in reverse domain notation. Appstream information won't be generated for ${component}.") 0077 endif() 0078 endfunction() 0079 0080 # See kpackage_install_package documentation above. 0081 # This function bundles the package into a Qt rcc file instead of installing 0082 # the individual files. Great care must be taken that the way package files are 0083 # accessed is actually rcc-compatible (e.g. package.fileUrl must be used and 0084 # manually constructed paths shouldn't treat the resources as file:// URLs 0085 # either). 0086 # Deprecated since 5.85, use kpackage_install_package instead. 0087 function(kpackage_install_bundled_package dir component) 0088 message(WARNING "kpackage_install_bundled_package is deprecated, use kpackage_install_package instead") 0089 set(root ${ARGV2}) 0090 set(install_dir ${ARGV3}) 0091 if(NOT root) 0092 set(root packages) 0093 endif() 0094 if(NOT install_dir) 0095 set(install_dir ${KPACKAGE_RELATIVE_DATA_INSTALL_DIR}) 0096 endif() 0097 0098 set(metadatajson) 0099 set(ORIGINAL_METADATA "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/metadata.desktop") 0100 if(NOT EXISTS ${component}-${root}-metadata.json AND EXISTS ${ORIGINAL_METADATA}) 0101 set(GENERATED_METADATA "${CMAKE_CURRENT_BINARY_DIR}/${component}-${root}-metadata.json") 0102 add_custom_target(${component}-${root}-metadata-json ALL DEPENDS ${GENERATED_METADATA}) 0103 kcoreaddons_desktop_to_json(${component}-${root}-metadata-json ${ORIGINAL_METADATA} 0104 OUTPUT_FILE ${GENERATED_METADATA}) 0105 install(FILES ${GENERATED_METADATA} DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component} RENAME metadata.json) 0106 set(metadatajson ${GENERATED_METADATA}) 0107 endif() 0108 0109 0110 get_target_property(kpackagetool_cmd KF5::kpackagetool5 LOCATION) 0111 if (${component} MATCHES "^.+\\..+\\.") #we make sure there's at least 2 dots 0112 set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml") 0113 0114 execute_process( 0115 COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/${dir} --appstream-metainfo-output ${APPDATAFILE} 0116 ERROR_VARIABLE appstreamerror 0117 RESULT_VARIABLE result) 0118 if (NOT result EQUAL 0) 0119 message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}") 0120 else() 0121 if(appstreamerror) 0122 message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}") 0123 endif() 0124 0125 # OPTIONAL because desktop files can be NoDisplay so they render no XML. 0126 install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR} OPTIONAL) 0127 endif() 0128 else() 0129 message(DEBUG "KPackage components should be specified in reverse domain notation. Appstream information won't be generated for ${component}.") 0130 endif() 0131 0132 set(kpkgqrc "${CMAKE_CURRENT_BINARY_DIR}/${component}.qrc") 0133 set(metadatajson ${metadatajson}) 0134 set(component ${component}) 0135 set(root ${root}) 0136 set(BINARYDIR ${CMAKE_CURRENT_BINARY_DIR}) 0137 set(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") 0138 set(OUTPUTFILE "${kpkgqrc}") 0139 add_custom_target(${component}-${root}-qrc ALL 0140 COMMAND ${CMAKE_COMMAND} -DINSTALL_DIR=${install_dir} -DROOT=${root} -DCOMPONENT=${component} -DDIRECTORY=${DIRECTORY} -D OUTPUTFILE=${OUTPUTFILE} -P ${kpackagedir}/qrc.cmake 0141 DEPENDS ${component}-${root}-metadata-json) 0142 set(GENERATED_RCC_CONTENTS "${CMAKE_CURRENT_BINARY_DIR}/${component}-contents.rcc") 0143 # add_custom_target depends on ALL target so qrc is run every time 0144 # it doesn't have OUTPUT property so it's considered out-of-date every build 0145 add_custom_target(${component}-${root}-contents-rcc ALL 0146 COMMENT "Generating ${component}-contents.rcc" 0147 COMMAND Qt${QT_MAJOR_VERSION}::rcc "${kpkgqrc}" --binary -o "${GENERATED_RCC_CONTENTS}" 0148 DEPENDS ${component}-${root}-metadata-json ${component}-${root}-qrc) 0149 install(FILES ${GENERATED_RCC_CONTENTS} DESTINATION ${KDE_INSTALL_DATADIR}/${install_dir}/${root}/${component}/ RENAME contents.rcc) 0150 0151 endfunction()