cmTestCommand.c 1.75 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1
2
3
4
5
6
7
8
9
10
11
12
#include "cmCPluginAPI.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

typedef struct 
{
  char *LibraryName;
} cmVTKWrapTclData;


/* do almost everything in the initial pass */
Andy Cedilnik's avatar
Andy Cedilnik committed
13
static int InitialPass(void *inf, void *mf, int argc, char *argv[])
Ken Martin's avatar
Ken Martin committed
14
15
16
17
18
19
20
21
{
  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;

  cmVTKWrapTclData *cdata = 
    (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData));
  cdata->LibraryName = "BOO";
  info->CAPI->SetClientData(info,cdata);
  
Ken Martin's avatar
Ken Martin committed
22
23
  /* Now check and see if the value has been stored in the cache */
  /* already, if so use that value and don't look for the program */
Ken Martin's avatar
Ken Martin committed
24
25
26
27
28
29
30
31
32
33
34
  if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1"))
    {
    info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");  
    return 1;
    }
  
  info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");  
  cdata->LibraryName = "HOO";
  return 1;
}

Andy Cedilnik's avatar
Andy Cedilnik committed
35
static void FinalPass(void *inf, void *mf) 
Ken Martin's avatar
Ken Martin committed
36
37
{
  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
Ken Martin's avatar
Ken Martin committed
38
  /* get our client data from initial pass */
Ken Martin's avatar
Ken Martin committed
39
40
41
42
43
44
45
46
47
  cmVTKWrapTclData *cdata = 
    (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
  if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") ||
      strcmp(cdata->LibraryName,"HOO"))
    {
    fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n");
    }
}

Andy Cedilnik's avatar
Andy Cedilnik committed
48
static void Destructor(void *inf) 
Ken Martin's avatar
Ken Martin committed
49
50
{
  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
Ken Martin's avatar
Ken Martin committed
51
  /* get our client data from initial pass */
Ken Martin's avatar
Ken Martin committed
52
53
54
55
56
  cmVTKWrapTclData *cdata = 
    (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
  free(cdata);
}

Ken Martin's avatar
Ken Martin committed
57
#ifdef MUCHO_MUDSLIDE
Ken Martin's avatar
Ken Martin committed
58
void CM_PLUGIN_EXPORT CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info)
Ken Martin's avatar
Ken Martin committed
59
60
61
{
  info->InitialPass = InitialPass;
  info->FinalPass = FinalPass;
Ken Martin's avatar
Ken Martin committed
62
  info->Destructor = Destructor;
Ken Martin's avatar
Ken Martin committed
63
  info->m_Inherited = 0;
Ken Martin's avatar
cleanup    
Ken Martin committed
64
  info->Name = "CMAKE_TEST_COMMAND";
Ken Martin's avatar
Ken Martin committed
65
}
Ken Martin's avatar
Ken Martin committed
66
#endif
Ken Martin's avatar
Ken Martin committed
67
68
69
70