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