1 #include "cmCPluginAPI.h"
13 /* do almost everything in the initial pass */
14 static int CCONV
InitialPass(void *inf
, void *mf
, int argc
, char *argv
[])
26 cmLoadedCommandInfo
*info
= (cmLoadedCommandInfo
*)inf
;
28 cmVTKWrapTclData
*cdata
=
29 (cmVTKWrapTclData
*)malloc(sizeof(cmVTKWrapTclData
));
30 cdata
->LibraryName
= "BOO";
33 info
->CAPI
->SetClientData(info
,cdata
);
35 /* Now check and see if the value has been stored in the cache */
36 /* already, if so use that value and don't look for the program */
37 if(!info
->CAPI
->IsOn(mf
,"TEST_COMMAND_TEST1"))
39 info
->CAPI
->AddDefinition(mf
, "TEST_DEF", "HOO");
43 info
->CAPI
->AddDefinition(mf
, "TEST_DEF", "HOO");
44 cdata
->LibraryName
= "HOO";
46 info
->CAPI
->AddCacheDefinition(mf
, "SOME_CACHE_VARIABLE", "ON",
47 "Test cache variable",
49 info
->CAPI
->AddCacheDefinition(mf
, "SOME_CACHE_VARIABLE1", "",
50 "Test cache variable 1",
52 info
->CAPI
->AddCacheDefinition(mf
, "SOME_CACHE_VARIABLE2", "",
53 "Test cache variable 2",
55 info
->CAPI
->AddCacheDefinition(mf
, "SOME_CACHE_VARIABLE3", "",
56 "Test cache variable 3",
58 info
->CAPI
->AddCacheDefinition(mf
, "SOME_CACHE_VARIABLE4", "",
59 "Test cache variable 4",
61 info
->CAPI
->AddCacheDefinition(mf
, "SOME_CACHE_VARIABLE5", "",
62 "Test cache variable 5",
66 file
= info
->CAPI
->ExpandVariablesInString(mf
, "${CMAKE_COMMAND}", 0, 0);
68 str
= info
->CAPI
->GetFilenameWithoutExtension(file
);
69 info
->CAPI
->DisplaySatus(mf
, str
);
70 info
->CAPI
->Free(str
);
71 str
= info
->CAPI
->GetFilenamePath(file
);
72 info
->CAPI
->DisplaySatus(mf
, str
);
73 info
->CAPI
->Free(str
);
74 str
= info
->CAPI
->Capitalized("cmake");
75 info
->CAPI
->DisplaySatus(mf
, str
);
76 info
->CAPI
->Free(str
);
78 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetProjectName(mf
));
79 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetHomeDirectory(mf
));
80 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetHomeOutputDirectory(mf
));
81 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetStartDirectory(mf
));
82 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetStartOutputDirectory(mf
));
83 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetCurrentDirectory(mf
));
84 info
->CAPI
->DisplaySatus(mf
, info
->CAPI
->GetCurrentOutputDirectory(mf
));
85 sprintf(buffer
, "Cache version: %d.%d, CMake version: %d.%d",
86 info
->CAPI
->GetCacheMajorVersion(mf
),
87 info
->CAPI
->GetCacheMinorVersion(mf
),
88 info
->CAPI
->GetMajorVersion(mf
),
89 info
->CAPI
->GetMinorVersion(mf
));
90 info
->CAPI
->DisplaySatus(mf
, buffer
);
91 if ( info
->CAPI
->CommandExists(mf
, "SET") )
93 info
->CAPI
->DisplaySatus(mf
, "Command SET exists");
95 if ( info
->CAPI
->CommandExists(mf
, "SET_FOO_BAR") )
97 info
->CAPI
->SetError(mf
, "Command SET_FOO_BAR should not exists");
100 info
->CAPI
->AddDefineFlag(mf
, "-DADDED_DEFINITION");
102 source_file
= info
->CAPI
->CreateNewSourceFile(mf
);
103 cstr
= info
->CAPI
->SourceFileGetSourceName(source_file
);
104 sprintf(buffer
, "Shold be empty (source file name): [%s]", cstr
);
105 info
->CAPI
->DisplaySatus(mf
, buffer
);
106 cstr
= info
->CAPI
->SourceFileGetFullPath(source_file
);
107 sprintf(buffer
, "Should be empty (source file full path): [%s]", cstr
);
108 info
->CAPI
->DisplaySatus(mf
, buffer
);
109 info
->CAPI
->DefineSourceFileProperty(mf
,"SOME_PROPERTY","unused old prop",
110 "This property is no longer used",
112 if ( info
->CAPI
->SourceFileGetPropertyAsBool(source_file
, "SOME_PROPERTY") )
114 info
->CAPI
->SetError(mf
, "Property SOME_PROPERTY should not be defined");
117 info
->CAPI
->DefineSourceFileProperty(mf
,"SOME_PROPERTY2","nice prop",
118 "This property is for testing.",
120 info
->CAPI
->SourceFileSetProperty(source_file
, "SOME_PROPERTY2", "HERE");
121 cstr
= info
->CAPI
->SourceFileGetProperty(source_file
, "ABSTRACT");
122 sprintf(buffer
, "Should be 0 (source file abstract property): [%p]", cstr
);
123 info
->CAPI
->DisplaySatus(mf
, buffer
);
125 info
->CAPI
->DestroySourceFile(source_file
);
128 info
->CAPI
->AddExecutable(mf
,"LoadedCommand",1, &srcs
, 0);
130 /* add customs commands to generate the source file */
135 ccDep
[0] = ccArgs
[2];
136 ccOut
[0] = ccArgs
[3];
137 info
->CAPI
->AddCustomCommand(mf
, "LoadedCommand.cxx.in",
147 ccDep
[0] = ccArgs
[2];
148 ccOut
[0] = ccArgs
[3];
149 info
->CAPI
->AddCustomCommandToOutput(mf
, ccOut
[0],
157 ccArgs
[2] = "Build has finished";
158 info
->CAPI
->AddCustomCommandToTarget(mf
, "LoadedCommand",
163 info
->CAPI
->Free(file
);
165 args
[0] = "TEST_EXEC";
169 if (info
->CAPI
->GetTotalArgumentSize(2,args
) != 13)
173 info
->CAPI
->ExecuteCommand(mf
,"SET",2,args
);
175 /* make sure we can find the source file */
176 if (!info
->CAPI
->GetSource(mf
,argv
[1]))
178 info
->CAPI
->SetError(mf
, "Source file could not be found!");
185 static void CCONV
FinalPass(void *inf
, void *mf
)
187 cmLoadedCommandInfo
*info
= (cmLoadedCommandInfo
*)inf
;
188 /* get our client data from initial pass */
189 cmVTKWrapTclData
*cdata
=
190 (cmVTKWrapTclData
*)info
->CAPI
->GetClientData(info
);
191 if (strcmp(info
->CAPI
->GetDefinition(mf
, "TEST_DEF"),"HOO") ||
192 strcmp(cdata
->LibraryName
,"HOO"))
194 fprintf(stderr
,"*** Failed LOADED COMMAND Final Pass\n");
197 static void CCONV
Destructor(void *inf
)
199 cmLoadedCommandInfo
*info
= (cmLoadedCommandInfo
*)inf
;
200 /* get our client data from initial pass */
201 cmVTKWrapTclData
*cdata
=
202 (cmVTKWrapTclData
*)info
->CAPI
->GetClientData(info
);
206 #ifdef MUCHO_MUDSLIDE
207 void CM_PLUGIN_EXPORT CCONV
CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo
*info
)
209 info
->InitialPass
= InitialPass
;
210 info
->FinalPass
= FinalPass
;
211 info
->Destructor
= Destructor
;
212 info
->m_Inherited
= 0;
213 info
->Name
= "CMAKE_TEST_COMMAND";