ctkFunctionGeneratePluginManifest.cmake 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #
  2. # Depends on:
  3. # CTK/CMake/ctkMacroParseArguments.cmake
  4. #
  5. #! \ingroup CMakeUtilities
  6. function(ctkFunctionGeneratePluginManifest QRC_SRCS)
  7. CtkMacroParseArguments(MY
  8. "ACTIVATIONPOLICY;CATEGORY;CONTACT_ADDRESS;COPYRIGHT;DESCRIPTION;DOC_URL;ICON;LICENSE;NAME;REQUIRE_PLUGIN;SYMBOLIC_NAME;VENDOR;VERSION;CUSTOM_HEADERS"
  9. ""
  10. ${ARGN}
  11. )
  12. # Sanity checks
  13. if(NOT DEFINED MY_SYMBOLIC_NAME)
  14. message(FATAL_ERROR "SYMBOLIC_NAME is mandatory")
  15. endif()
  16. set(_manifest_content "Plugin-SymbolicName: ${MY_SYMBOLIC_NAME}")
  17. if(DEFINED MY_ACTIVATIONPOLICY)
  18. string(TOLOWER "${MY_ACTIVATIONPOLICY}" _activation_policy)
  19. if(_activation_policy STREQUAL "eager")
  20. set(_manifest_content "${_manifest_content}\nPlugin-ActivationPolicy: eager")
  21. else()
  22. message(FATAL_ERROR "ACTIVATIONPOLICY is set to '${MY_ACTIVATIONPOLICY}', which is not supported")
  23. endif()
  24. endif()
  25. if(DEFINED MY_CATEGORY)
  26. set(_manifest_content "${_manifest_content}\nPlugin-Category: ${MY_CATEGORY}")
  27. endif()
  28. if(DEFINED MY_CONTACT_ADDRESS)
  29. set(_manifest_content "${_manifest_content}\nPlugin-ContactAddress: ${MY_CONTACT_ADDRESS}")
  30. endif()
  31. if(DEFINED MY_COPYRIGHT)
  32. set(_manifest_content "${_manifest_content}\nPlugin-Copyright: ${MY_COPYRIGHT}")
  33. endif()
  34. if(DEFINED MY_DESCRIPTION)
  35. set(_manifest_content "${_manifest_content}\nPlugin-Description: ${MY_DESCRIPTION}")
  36. endif()
  37. if(DEFINED MY_DOC_URL)
  38. set(_manifest_content "${_manifest_content}\nPlugin-DocURL: ${MY_DOC_URL}")
  39. endif()
  40. if(DEFINED MY_ICON)
  41. set(_manifest_content "${_manifest_content}\nPlugin-Icon: ${MY_ICON}")
  42. endif()
  43. if(DEFINED MY_LICENSE)
  44. set(_manifest_content "${_manifest_content}\nPlugin-License: ${MY_LICENSE}")
  45. endif()
  46. if(DEFINED MY_NAME)
  47. set(_manifest_content "${_manifest_content}\nPlugin-Name: ${MY_NAME}")
  48. endif()
  49. if(DEFINED MY_REQUIRE_PLUGIN)
  50. string(REPLACE ";" "," require_plugin "${MY_REQUIRE_PLUGIN}")
  51. set(_manifest_content "${_manifest_content}\nRequire-Plugin: ${require_plugin}")
  52. endif()
  53. if(DEFINED MY_VENDOR)
  54. set(_manifest_content "${_manifest_content}\nPlugin-Vendor: ${MY_VENDOR}")
  55. endif()
  56. if(DEFINED MY_VERSION)
  57. set(_manifest_content "${_manifest_content}\nPlugin-Version: ${MY_VERSION}")
  58. endif()
  59. if(DEFINED MY_CUSTOM_HEADERS)
  60. set(_manifest_content "${_manifest_content}\n")
  61. foreach(_custom_header ${MY_CUSTOM_HEADERS})
  62. set(_manifest_content "${_manifest_content}\n${_custom_header}: ${${_custom_header}}")
  63. endforeach()
  64. endif()
  65. set(_manifest_filename "MANIFEST.MF")
  66. set(_manifest_filepath "${CMAKE_CURRENT_BINARY_DIR}/${_manifest_filename}")
  67. string(REPLACE "." "_" _symbolic_name ${MY_SYMBOLIC_NAME})
  68. set(_manifest_qrc_filepath "${CMAKE_CURRENT_BINARY_DIR}/${_symbolic_name}_manifest.qrc")
  69. set(_manifest_qrc_content
  70. "<!DOCTYPE RCC><RCC version=\"1.0\">
  71. <qresource prefix=\"/${MY_SYMBOLIC_NAME}/META-INF\">
  72. <file>${_manifest_filename}</file>
  73. </qresource>
  74. </RCC>
  75. ")
  76. configure_file("${CTK_CMAKE_DIR}/MANIFEST.MF.in" "${_manifest_filepath}" @ONLY)
  77. configure_file("${CTK_CMAKE_DIR}/plugin_manifest.qrc.in" "${_manifest_qrc_filepath}" @ONLY)
  78. if (CTK_QT_VERSION VERSION_GREATER "4")
  79. QT5_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
  80. else()
  81. QT4_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
  82. endif()
  83. set(${QRC_SRCS} ${${QRC_SRCS}} ${_qrc_src} PARENT_SCOPE)
  84. endfunction()