ctkFunctionGeneratePluginManifest.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # Depends on:
  3. # CTK/CMake/ctkMacroParseArguments.cmake
  4. #
  5. FUNCTION(ctkFunctionGeneratePluginManifest QRC_SRCS)
  6. CtkMacroParseArguments(MY
  7. "ACTIVATIONPOLICY;CATEGORY;CONTACT_ADDRESS;COPYRIGHT;DESCRIPTION;DOC_URL;ICON;LICENSE;NAME;REQUIRE_PLUGIN;SYMBOLIC_NAME;VENDOR;VERSION"
  8. ""
  9. ${ARGN}
  10. )
  11. # Sanity checks
  12. IF(NOT DEFINED MY_SYMBOLIC_NAME)
  13. MESSAGE(SEND_ERROR "SYMBOLIC_NAME is mandatory")
  14. ENDIF()
  15. SET(_manifest_content "Plugin-SymbolicName: ${MY_SYMBOLIC_NAME}")
  16. IF(DEFINED MY_ACTIVATIONPOLICY)
  17. STRING(TOLOWER "${MY_ACTIVATIONPOLICY}" _activation_policy)
  18. IF(_activation_policy STREQUAL "eager")
  19. SET(_manifest_content "${_manifest_content}\nPlugin-ActivationPolicy: eager")
  20. ELSE()
  21. MESSAGE(SEND_ERROR "ACTIVATIONPOLICY is set to '${MY_ACTIVATIONPOLICY}', which is not supported")
  22. ENDIF()
  23. ENDIF()
  24. IF(DEFINED MY_CATEGORY)
  25. SET(_manifest_content "${_manifest_content}\nPlugin-Category: ${MY_CATEGORY}")
  26. ENDIF()
  27. IF(DEFINED MY_CONTACT_ADDRESS)
  28. SET(_manifest_content "${_manifest_content}\nPlugin-ContactAddress: ${MY_CONTACT_ADDRESS}")
  29. ENDIF()
  30. IF(DEFINED MY_COPYRIGHT)
  31. SET(_manifest_content "${_manifest_content}\nPlugin-Copyright: ${MY_COPYRIGHT}")
  32. ENDIF()
  33. IF(DEFINED MY_DESCRIPTION)
  34. SET(_manifest_content "${_manifest_content}\nPlugin-Description: ${MY_DESCRIPTION}")
  35. ENDIF()
  36. IF(DEFINED MY_DOC_URL)
  37. SET(_manifest_content "${_manifest_content}\nPlugin-DocURL: ${MY_DOC_URL}")
  38. ENDIF()
  39. IF(DEFINED MY_ICON)
  40. SET(_manifest_content "${_manifest_content}\nPlugin-Icon: ${MY_ICON}")
  41. ENDIF()
  42. IF(DEFINED MY_LICENSE)
  43. SET(_manifest_content "${_manifest_content}\nPlugin-License: ${MY_LICENSE}")
  44. ENDIF()
  45. IF(DEFINED MY_NAME)
  46. SET(_manifest_content "${_manifest_content}\nPlugin-Name: ${MY_NAME}")
  47. ENDIF()
  48. IF(DEFINED MY_REQUIRE_PLUGIN)
  49. STRING(REPLACE ";" "," require_plugin "${MY_REQUIRE_PLUGIN}")
  50. SET(_manifest_content "${_manifest_content}\nRequire-Plugin: ${require_plugin}")
  51. ENDIF()
  52. IF(DEFINED MY_VENDOR)
  53. SET(_manifest_content "${_manifest_content}\nPlugin-Vendor: ${MY_VENDOR}")
  54. ENDIF()
  55. IF(DEFINED MY_VERSION)
  56. SET(_manifest_content "${_manifest_content}\nPlugin-Version: ${MY_VERSION}")
  57. ENDIF()
  58. SET(_manifest_filename "MANIFEST.MF")
  59. SET(_manifest_filepath "${CMAKE_CURRENT_BINARY_DIR}/${_manifest_filename}")
  60. STRING(REPLACE "." "_" _symbolic_name ${MY_SYMBOLIC_NAME})
  61. SET(_manifest_qrc_filepath "${CMAKE_CURRENT_BINARY_DIR}/${_symbolic_name}_manifest.qrc")
  62. SET(_manifest_qrc_content
  63. "<!DOCTYPE RCC><RCC version=\"1.0\">
  64. <qresource prefix=\"/${MY_SYMBOLIC_NAME}/META-INF\">
  65. <file>${_manifest_filename}</file>
  66. </qresource>
  67. </RCC>
  68. ")
  69. FILE(WRITE "${_manifest_filepath}" "${_manifest_content}")
  70. FILE(WRITE "${_manifest_qrc_filepath}" "${_manifest_qrc_content}")
  71. QT4_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
  72. SET(${QRC_SRCS} ${${QRC_SRCS}} ${_qrc_src} PARENT_SCOPE)
  73. ENDFUNCTION()