cmCPluginAPI.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. /* This header file defines the API that loadable commands can use. In many
  14. of these commands C++ instances of cmMakefile of cmSourceFile are passed
  15. in as arguments or returned. In these cases they are passed as a void *
  16. argument. In the function prototypes mf is used to represent a makefile
  17. and sf is used to represent a source file. The functions are grouped
  18. loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4)
  19. cmSystemTools. Within each grouping functions are listed alphabetically */
  20. /*=========================================================================*/
  21. /*=========================================================================*/
  22. /* CM_PLUGIN_EXPORT should be used by plugins */
  23. /*=========================================================================*/
  24. #ifdef _WIN32
  25. #define CM_PLUGIN_EXPORT __declspec( dllexport )
  26. #else
  27. #define CM_PLUGIN_EXPORT
  28. #endif
  29. /*=========================================================================*/
  30. /* CM_EXPORT is used by CMake and not by plugins */
  31. /*=========================================================================*/
  32. #ifndef CM_EXPORT
  33. #ifdef _WIN32
  34. #ifdef CMakeLib_EXPORTS
  35. #define CM_EXPORT __declspec( dllexport )
  36. #else
  37. #define CM_EXPORT __declspec( dllimport )
  38. #endif
  39. #else
  40. #define CM_EXPORT
  41. #endif
  42. #endif
  43. /*=========================================================================*/
  44. /* define the different types of cache entries, see cmCacheManager.h for more
  45. information */
  46. /*=========================================================================*/#define CM_CACHE_BOOL 0
  47. #define CM_CACHE_PATH 1
  48. #define CM_CACHE_FILEPATH 2
  49. #define CM_CACHE_STRING 3
  50. #define CM_CACHE_INTERNAL 4
  51. #define CM_CACHE_STATIC 5
  52. /*=========================================================================*/
  53. /* define the different types of compiles a library may be */
  54. /*=========================================================================*/
  55. #define CM_LIBRARY_GENERAL 0
  56. #define CM_LIBRARY_DEBUG 1
  57. #define CM_LIBRARY_OPTIMIZED 2
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /*=========================================================================*/
  62. /* first we define the key data structures and function prototypes */
  63. /*=========================================================================*/
  64. typedef const char* (*CM_DOC_FUNCTION)();
  65. typedef const char* (*CM_NAME_FUNCTION)();
  66. typedef int (*CM_INITIAL_PASS_FUNCTION)(void *info, void *mf,
  67. int argc, char *[]);
  68. typedef void (*CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
  69. typedef struct {
  70. int m_Inherited;
  71. CM_INITIAL_PASS_FUNCTION InitialPass;
  72. CM_FINAL_PASS_FUNCTION FinalPass;
  73. CM_DOC_FUNCTION GetTerseDocumentation;
  74. CM_DOC_FUNCTION GetFullDocumentation;
  75. void *ClientData;
  76. } cmLoadedCommandInfo;
  77. typedef void (*CM_INIT_FUNCTION)(cmLoadedCommandInfo *);
  78. /*=========================================================================*/
  79. /* Finally we define the set of functions that a plugin may call. The first
  80. goup of functions are utility functions that are specific to the plugin
  81. API */
  82. /*=========================================================================*/
  83. /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
  84. information is passed from the InitialPass to FInalPass for commands
  85. that need a FinalPass and need information from the InitialPass */
  86. extern CM_EXPORT void *cmGetClientData(void *info);
  87. /* return the summed size in characters of all the arguments */
  88. extern CM_EXPORT int cmGetTotalArgumentSize(int argc, char **argv);
  89. /* free all the memory associated with an argc, argv pair */
  90. extern CM_EXPORT void cmFreeArguments(int argc, char **argv);
  91. /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
  92. information is passed from the InitialPass to FInalPass for commands
  93. that need a FinalPass and need information from the InitialPass */
  94. extern CM_EXPORT void cmSetClientData(void *info, void *cd);
  95. /*=========================================================================*/
  96. /* The following functions all directly map to methods in the cmMakefile
  97. class. See cmMakefile.h for descriptions of what each method does. All
  98. of these methods take the void * makefile pointer as their first
  99. argument. */
  100. /*=========================================================================*/
  101. extern CM_EXPORT void cmAddCacheDefinition(void *mf, const char* name,
  102. const char* value,
  103. const char* doc,
  104. int cachetype);
  105. extern CM_EXPORT void cmAddCustomCommand(void *mf, const char* source,
  106. const char* command,
  107. int numArgs,
  108. const char **args,
  109. int numDepends,
  110. const char **depends,
  111. int numOutputs,
  112. const char **outputs,
  113. const char *target);
  114. extern CM_EXPORT void cmAddDefineFlag(void *mf, const char* definition);
  115. extern CM_EXPORT void cmAddDefinition(void *mf, const char* name,
  116. const char* value);
  117. extern CM_EXPORT void cmAddExecutable(void *mf, const char *exename,
  118. int numSrcs, const char **srcs,
  119. int win32);
  120. extern CM_EXPORT void cmAddLibrary(void *mf, const char *libname,
  121. int shared, int numSrcs,
  122. const char **srcs);
  123. extern CM_EXPORT void cmAddLinkDirectoryForTarget(void *mf,
  124. const char *tgt,
  125. const char* d);
  126. extern CM_EXPORT void cmAddLinkLibraryForTarget(void *mf,
  127. const char *tgt,
  128. const char *libname,
  129. int libtype);
  130. extern CM_EXPORT void cmAddUtilityCommand(void *mf, const char* utilityName,
  131. const char *command,
  132. const char *arguments,
  133. int all, int numDepends,
  134. const char **depends,
  135. int numOutputs,
  136. const char **outputs);
  137. extern CM_EXPORT int cmCommandExists(void *mf, const char* name);
  138. extern CM_EXPORT void cmExecuteCommand(void *mf, const char *name,
  139. int numArgs, const char **args);
  140. extern CM_EXPORT
  141. void cmExpandSourceListArguments(void *mf,int argc, const char **argv,
  142. int *resArgc, char ***resArgv,
  143. unsigned int startArgumentIndex);
  144. extern CM_EXPORT char *cmExpandVariablesInString(void *mf,
  145. const char *source,
  146. int escapeQuotes,
  147. int atOnly);
  148. extern CM_EXPORT unsigned int cmGetCacheMajorVersion(void *mf);
  149. extern CM_EXPORT unsigned int cmGetCacheMinorVersion(void *mf);
  150. extern CM_EXPORT const char* cmGetCurrentDirectory(void *mf);
  151. extern CM_EXPORT const char* cmGetCurrentOutputDirectory(void *mf);
  152. extern CM_EXPORT const char* cmGetDefinition(void *mf, const char *def);
  153. extern CM_EXPORT const char* cmGetHomeDirectory(void *mf);
  154. extern CM_EXPORT const char* cmGetHomeOutputDirectory(void *mf);
  155. extern CM_EXPORT unsigned int cmGetMajorVersion(void *mf);
  156. extern CM_EXPORT unsigned int cmGetMinorVersion(void *mf);
  157. extern CM_EXPORT const char* cmGetProjectName(void *mf);
  158. extern CM_EXPORT const char* cmGetStartDirectory(void *mf);
  159. extern CM_EXPORT const char* cmGetStartOutputDirectory(void *mf);
  160. extern CM_EXPORT int cmIsOn(void *mf, const char* name);
  161. /*=========================================================================*/
  162. /* The following functions are designed to operate or manipulate
  163. cmSourceFiles. Please see cmSourceFile.h for additional information on many
  164. of these methods. Some of these methods are in cmMakefile.h.
  165. /*=========================================================================*/
  166. extern CM_EXPORT void *cmAddSource(void *mf, void *sf);
  167. extern CM_EXPORT void *cmCreateSourceFile();
  168. extern CM_EXPORT void *cmGetSource(void *mf, const char* sourceName);
  169. extern CM_EXPORT void cmSourceFileAddDepend(void *sf, const char *depend);
  170. extern CM_EXPORT const char *cmSourceFileGetProperty(void *sf,
  171. const char *prop);
  172. extern CM_EXPORT int cmSourceFileGetPropertyAsBool(void *sf,
  173. const char *prop);
  174. extern CM_EXPORT const char *cmSourceFileGetSourceName(void *sf);
  175. extern CM_EXPORT
  176. void cmSourceFileSetName(void *sf, const char* name, const char* dir,
  177. int numSourceExtensions,
  178. const char **sourceExtensions,
  179. int numHeaderExtensions,
  180. const char **headerExtensions);
  181. extern CM_EXPORT
  182. void cmSourceFileSetName2(void *sf, const char* name, const char* dir,
  183. const char *ext, int headerFileOnly);
  184. extern CM_EXPORT void cmSourceFileSetProperty(void *sf, const char *prop,
  185. const char *value);
  186. /*=========================================================================*/
  187. /* the following methods are from cmSystemTools.h see that file for
  188. specific documentaiton on each method. */
  189. /*=========================================================================*/
  190. extern CM_EXPORT char *cmCapitalized(const char *);
  191. extern CM_EXPORT void cmCopyFileIfDifferent(const char *f1, const char *f2);
  192. extern CM_EXPORT char *cmGetFilenameWithoutExtension(const char *);
  193. extern CM_EXPORT void cmRemoveFile(const char *f1);
  194. #ifdef __cplusplus
  195. }
  196. #endif