1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCPluginAPI.cxx,v $
6 <<<<<<< cmCPluginAPI.cxx
7 Date: $Date: 2008/01/23 15:27:59 $
8 Version: $Revision: 1.42 $
10 Date: $Date: 2009-03-16 18:30:24 $
11 Version: $Revision: 1.43 $
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
23 this file contains the implementation of the C API to CMake. Generally
24 these routines just manipulate arguments and then call the associated
25 methods on the CMake classes. */
27 #include "cmMakefile.h"
28 #include "cmCPluginAPI.h"
29 #include "cmVersion.h"
31 #include "cmSourceFile.h"
36 # include <malloc.h> /* for malloc/free on QNX */
42 void CCONV
*cmGetClientData(void *info
)
44 return ((cmLoadedCommandInfo
*)info
)->ClientData
;
47 void CCONV
cmSetClientData(void *info
, void *cd
)
49 ((cmLoadedCommandInfo
*)info
)->ClientData
= cd
;
52 void CCONV
cmSetError(void *info
, const char *err
)
54 if (((cmLoadedCommandInfo
*)info
)->Error
)
56 free(((cmLoadedCommandInfo
*)info
)->Error
);
58 ((cmLoadedCommandInfo
*)info
)->Error
= strdup(err
);
61 unsigned int CCONV
cmGetCacheMajorVersion(void *arg
)
63 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
64 return mf
->GetCacheMajorVersion();
66 unsigned int CCONV
cmGetCacheMinorVersion(void *arg
)
68 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
69 return mf
->GetCacheMinorVersion();
72 unsigned int CCONV
cmGetMajorVersion(void *)
74 return cmVersion::GetMajorVersion();
77 unsigned int CCONV
cmGetMinorVersion(void *)
79 return cmVersion::GetMinorVersion();
82 void CCONV
cmAddDefinition(void *arg
, const char* name
, const char* value
)
84 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
85 mf
->AddDefinition(name
,value
);
88 /* Add a definition to this makefile and the global cmake cache. */
89 void CCONV
cmAddCacheDefinition(void *arg
, const char* name
,
90 const char* value
, const char* doc
, int type
)
92 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
97 mf
->AddCacheDefinition(name
,value
,doc
,
98 cmCacheManager::BOOL
);
101 mf
->AddCacheDefinition(name
,value
,doc
,
102 cmCacheManager::PATH
);
104 case CM_CACHE_FILEPATH
:
105 mf
->AddCacheDefinition(name
,value
,doc
,
106 cmCacheManager::FILEPATH
);
108 case CM_CACHE_STRING
:
109 mf
->AddCacheDefinition(name
,value
,doc
,
110 cmCacheManager::STRING
);
112 case CM_CACHE_INTERNAL
:
113 mf
->AddCacheDefinition(name
,value
,doc
,
114 cmCacheManager::INTERNAL
);
116 case CM_CACHE_STATIC
:
117 mf
->AddCacheDefinition(name
,value
,doc
,
118 cmCacheManager::STATIC
);
123 const char* CCONV
cmGetProjectName(void *arg
)
125 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
126 return mf
->GetProjectName();
129 const char* CCONV
cmGetHomeDirectory(void *arg
)
131 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
132 return mf
->GetHomeDirectory();
134 const char* CCONV
cmGetHomeOutputDirectory(void *arg
)
136 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
137 return mf
->GetHomeOutputDirectory();
139 const char* CCONV
cmGetStartDirectory(void *arg
)
141 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
142 return mf
->GetStartDirectory();
144 const char* CCONV
cmGetStartOutputDirectory(void *arg
)
146 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
147 return mf
->GetStartOutputDirectory();
149 const char* CCONV
cmGetCurrentDirectory(void *arg
)
151 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
152 return mf
->GetCurrentDirectory();
154 const char* CCONV
cmGetCurrentOutputDirectory(void *arg
)
156 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
157 return mf
->GetCurrentOutputDirectory();
159 const char* CCONV
cmGetDefinition(void *arg
,const char*def
)
161 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
162 return mf
->GetDefinition(def
);
165 int CCONV
cmIsOn(void *arg
, const char* name
)
167 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
168 return static_cast<int>(mf
->IsOn(name
));
171 /** Check if a command exists. */
172 int CCONV
cmCommandExists(void *arg
, const char* name
)
174 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
175 return static_cast<int>(mf
->CommandExists(name
));
178 void CCONV
cmAddDefineFlag(void *arg
, const char* definition
)
180 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
181 mf
->AddDefineFlag(definition
);
184 void CCONV
cmAddLinkDirectoryForTarget(void *arg
, const char *tgt
,
187 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
188 mf
->AddLinkDirectoryForTarget(tgt
,d
);
192 void CCONV
cmAddExecutable(void *arg
, const char *exename
,
193 int numSrcs
, const char **srcs
, int win32
)
195 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
196 std::vector
<std::string
> srcs2
;
198 for (i
= 0; i
< numSrcs
; ++i
)
200 srcs2
.push_back(srcs
[i
]);
202 cmTarget
* tg
= mf
->AddExecutable(exename
, srcs2
);
205 tg
->SetProperty("WIN32_EXECUTABLE", "ON");
209 void CCONV
cmAddUtilityCommand(void *arg
, const char* utilityName
,
211 const char* arguments
,
214 const char **depends
,
218 // Get the makefile instance. Perform an extra variable expansion
219 // now because the API caller expects it.
220 cmMakefile
* mf
= static_cast<cmMakefile
*>(arg
);
222 // Construct the command line for the command.
223 cmCustomCommandLine commandLine
;
224 std::string expand
= command
;
225 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
226 if(arguments
&& arguments
[0])
228 // TODO: Parse arguments!
230 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
232 cmCustomCommandLines commandLines
;
233 commandLines
.push_back(commandLine
);
235 // Accumulate the list of dependencies.
236 std::vector
<std::string
> depends2
;
237 for(int i
= 0; i
< numDepends
; ++i
)
240 depends2
.push_back(mf
->ExpandVariablesInString(expand
));
243 // Pass the call to the makefile instance.
244 mf
->AddUtilityCommand(utilityName
, (all
? false : true),
245 0, depends2
, commandLines
);
247 void CCONV
cmAddCustomCommand(void *arg
, const char* source
,
249 int numArgs
, const char **args
,
250 int numDepends
, const char **depends
,
251 int numOutputs
, const char **outputs
,
254 // Get the makefile instance. Perform an extra variable expansion
255 // now because the API caller expects it.
256 cmMakefile
* mf
= static_cast<cmMakefile
*>(arg
);
258 // Construct the command line for the command.
259 cmCustomCommandLine commandLine
;
260 std::string expand
= command
;
261 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
262 for(int i
=0; i
< numArgs
; ++i
)
265 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
267 cmCustomCommandLines commandLines
;
268 commandLines
.push_back(commandLine
);
270 // Accumulate the list of dependencies.
271 std::vector
<std::string
> depends2
;
272 for(int i
= 0; i
< numDepends
; ++i
)
275 depends2
.push_back(mf
->ExpandVariablesInString(expand
));
278 // Accumulate the list of outputs.
279 std::vector
<std::string
> outputs2
;
280 for(int i
= 0; i
< numOutputs
; ++i
)
283 outputs2
.push_back(mf
->ExpandVariablesInString(expand
));
286 // Pass the call to the makefile instance.
287 const char* no_comment
= 0;
288 mf
->AddCustomCommandOldStyle(target
, outputs2
, depends2
, source
,
289 commandLines
, no_comment
);
292 void CCONV
cmAddCustomCommandToOutput(void *arg
, const char* output
,
294 int numArgs
, const char **args
,
295 const char* main_dependency
,
296 int numDepends
, const char **depends
)
298 // Get the makefile instance. Perform an extra variable expansion
299 // now because the API caller expects it.
300 cmMakefile
* mf
= static_cast<cmMakefile
*>(arg
);
302 // Construct the command line for the command.
303 cmCustomCommandLine commandLine
;
304 std::string expand
= command
;
305 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
306 for(int i
=0; i
< numArgs
; ++i
)
309 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
311 cmCustomCommandLines commandLines
;
312 commandLines
.push_back(commandLine
);
314 // Accumulate the list of dependencies.
315 std::vector
<std::string
> depends2
;
316 for(int i
= 0; i
< numDepends
; ++i
)
319 depends2
.push_back(mf
->ExpandVariablesInString(expand
));
322 // Pass the call to the makefile instance.
323 const char* no_comment
= 0;
324 const char* no_working_dir
= 0;
325 mf
->AddCustomCommandToOutput(output
, depends2
, main_dependency
,
326 commandLines
, no_comment
, no_working_dir
);
329 void CCONV
cmAddCustomCommandToTarget(void *arg
, const char* target
,
331 int numArgs
, const char **args
,
334 // Get the makefile instance.
335 cmMakefile
* mf
= static_cast<cmMakefile
*>(arg
);
337 // Construct the command line for the command. Perform an extra
338 // variable expansion now because the API caller expects it.
339 cmCustomCommandLine commandLine
;
340 std::string expand
= command
;
341 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
342 for(int i
=0; i
< numArgs
; ++i
)
345 commandLine
.push_back(mf
->ExpandVariablesInString(expand
));
347 cmCustomCommandLines commandLines
;
348 commandLines
.push_back(commandLine
);
350 // Select the command type.
351 cmTarget::CustomCommandType cctype
= cmTarget::POST_BUILD
;
355 cctype
= cmTarget::PRE_BUILD
;
358 cctype
= cmTarget::PRE_LINK
;
361 cctype
= cmTarget::POST_BUILD
;
365 // Pass the call to the makefile instance.
366 std::vector
<std::string
> no_depends
;
367 const char* no_comment
= 0;
368 const char* no_working_dir
= 0;
369 mf
->AddCustomCommandToTarget(target
, no_depends
, commandLines
,
370 cctype
, no_comment
, no_working_dir
);
373 void CCONV
cmAddLinkLibraryForTarget(void *arg
, const char *tgt
,
374 const char*value
, int libtype
)
376 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
380 case CM_LIBRARY_GENERAL
:
381 mf
->AddLinkLibraryForTarget(tgt
,value
, cmTarget::GENERAL
);
383 case CM_LIBRARY_DEBUG
:
384 mf
->AddLinkLibraryForTarget(tgt
,value
, cmTarget::DEBUG
);
386 case CM_LIBRARY_OPTIMIZED
:
387 mf
->AddLinkLibraryForTarget(tgt
,value
, cmTarget::OPTIMIZED
);
392 void CCONV
cmAddLibrary(void *arg
, const char *libname
, int shared
,
393 int numSrcs
, const char **srcs
)
395 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
396 std::vector
<std::string
> srcs2
;
398 for (i
= 0; i
< numSrcs
; ++i
)
400 srcs2
.push_back(srcs
[i
]);
402 mf
->AddLibrary(libname
,
403 (shared
? cmTarget::SHARED_LIBRARY
: cmTarget::STATIC_LIBRARY
),
407 char CCONV
*cmExpandVariablesInString(void *arg
, const char *source
,
408 int escapeQuotes
, int atOnly
)
410 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
411 std::string barf
= source
;
413 mf
->ExpandVariablesInString(barf
,
414 (escapeQuotes
? true : false),
415 (atOnly
? true : false));
416 char *res
= static_cast<char *>(malloc(result
.size() + 1));
419 strcpy(res
,result
.c_str());
421 res
[result
.size()] = '\0';
426 int CCONV
cmExecuteCommand(void *arg
, const char *name
,
427 int numArgs
, const char **args
)
429 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
430 cmListFileFunction lff
;
432 for(int i
= 0; i
< numArgs
; ++i
)
434 // Assume all arguments are quoted.
435 lff
.Arguments
.push_back(cmListFileArgument(args
[i
], true,
436 "[CMake-Plugin]", 0));
438 cmExecutionStatus status
;
439 return mf
->ExecuteCommand(lff
,status
);
442 void CCONV
cmExpandSourceListArguments(void *arg
,
447 unsigned int startArgumentIndex
)
449 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
450 std::vector
<std::string
> result
;
451 std::vector
<std::string
> args2
;
453 for (i
= 0; i
< numArgs
; ++i
)
455 args2
.push_back(args
[i
]);
457 mf
->ExpandSourceListArguments(args2
, result
, startArgumentIndex
);
458 int resargc
= static_cast<int>(result
.size());
462 resargv
= (char **)malloc(resargc
*sizeof(char *));
464 for (i
= 0; i
< resargc
; ++i
)
466 resargv
[i
] = strdup(result
[i
].c_str());
472 void CCONV
cmFreeArguments(int argc
, char **argv
)
475 for (i
= 0; i
< argc
; ++i
)
485 int CCONV
cmGetTotalArgumentSize(int argc
, char **argv
)
489 for (i
= 0; i
< argc
; ++i
)
493 result
= result
+ static_cast<int>(strlen(argv
[i
]));
499 // Source file proxy object to support the old cmSourceFile/cmMakefile
500 // API for source files.
501 struct cmCPluginAPISourceFile
503 cmCPluginAPISourceFile(): RealSourceFile(0) {}
504 cmSourceFile
* RealSourceFile
;
505 std::string SourceName
;
506 std::string SourceExtension
;
507 std::string FullPath
;
508 std::vector
<std::string
> Depends
;
509 cmPropertyMap Properties
;
512 // Keep a map from real cmSourceFile instances stored in a makefile to
513 // the CPluginAPI proxy source file.
514 class cmCPluginAPISourceFileMap
:
515 public std::map
<cmSourceFile
*, cmCPluginAPISourceFile
*>
518 typedef std::map
<cmSourceFile
*, cmCPluginAPISourceFile
*> derived
;
519 typedef derived::iterator iterator
;
520 typedef derived::value_type value_type
;
521 ~cmCPluginAPISourceFileMap()
523 for(iterator i
=this->begin(); i
!= this->end(); ++i
)
529 cmCPluginAPISourceFileMap cmCPluginAPISourceFiles
;
531 void * CCONV
cmCreateSourceFile()
533 return (void*)new cmCPluginAPISourceFile
;
536 void * CCONV
cmCreateNewSourceFile(void *arg
)
538 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
539 cmCPluginAPISourceFile
*sf
= new cmCPluginAPISourceFile
;
540 sf
->Properties
.SetCMakeInstance(mf
->GetCMakeInstance());
544 void CCONV
cmDestroySourceFile(void *arg
)
546 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
547 // Only delete if it was created by cmCreateSourceFile or
548 // cmCreateNewSourceFile and is therefore not in the map.
549 if(!sf
->RealSourceFile
)
555 void CCONV
*cmGetSource(void *arg
, const char *name
)
557 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
558 if(cmSourceFile
* rsf
= mf
->GetSource(name
))
560 // Lookup the proxy source file object for this source.
561 cmCPluginAPISourceFileMap::iterator i
= cmCPluginAPISourceFiles
.find(rsf
);
562 if(i
== cmCPluginAPISourceFiles
.end())
564 // Create a proxy source file object for this source.
565 cmCPluginAPISourceFile
* sf
= new cmCPluginAPISourceFile
;
566 sf
->RealSourceFile
= rsf
;
567 sf
->FullPath
= rsf
->GetFullPath();
569 cmSystemTools::GetFilenameWithoutLastExtension(sf
->FullPath
.c_str());
570 sf
->SourceExtension
=
571 cmSystemTools::GetFilenameLastExtension(sf
->FullPath
.c_str());
573 // Store the proxy in the map so it can be re-used and deleted later.
574 cmCPluginAPISourceFileMap::value_type
entry(rsf
, sf
);
575 i
= cmCPluginAPISourceFiles
.insert(entry
).first
;
577 return (void *)i
->second
;
585 void * CCONV
cmAddSource(void *arg
, void *arg2
)
587 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
588 cmCPluginAPISourceFile
* osf
= static_cast<cmCPluginAPISourceFile
*>(arg2
);
589 if(osf
->FullPath
.empty())
594 // Create the real cmSourceFile instance and copy over saved information.
595 cmSourceFile
* rsf
= mf
->GetOrCreateSource(osf
->FullPath
.c_str());
596 rsf
->GetProperties() = osf
->Properties
;
597 for(std::vector
<std::string
>::iterator i
= osf
->Depends
.begin();
598 i
!= osf
->Depends
.end(); ++i
)
600 rsf
->AddDepend(i
->c_str());
603 // Create the proxy for the real source file.
604 cmCPluginAPISourceFile
* sf
= new cmCPluginAPISourceFile
;
605 sf
->RealSourceFile
= rsf
;
606 sf
->FullPath
= osf
->FullPath
;
607 sf
->SourceName
= osf
->SourceName
;
608 sf
->SourceExtension
= osf
->SourceExtension
;
610 // Store the proxy in the map so it can be re-used and deleted later.
611 cmCPluginAPISourceFiles
[rsf
] = sf
;
615 const char * CCONV
cmSourceFileGetSourceName(void *arg
)
617 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
618 return sf
->SourceName
.c_str();
621 const char * CCONV
cmSourceFileGetFullPath(void *arg
)
623 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
624 return sf
->FullPath
.c_str();
627 const char * CCONV
cmSourceFileGetProperty(void *arg
,const char *prop
)
629 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
630 if(cmSourceFile
* rsf
= sf
->RealSourceFile
)
632 return rsf
->GetProperty(prop
);
636 if(!strcmp(prop
,"LOCATION"))
638 return sf
->FullPath
.c_str();
641 // Ignore chain because old code will not expect it and it is a
642 // pain to implement here anyway.
643 return sf
->Properties
.GetPropertyValue(prop
, cmProperty::SOURCE_FILE
,
648 int CCONV
cmSourceFileGetPropertyAsBool(void *arg
,const char *prop
)
650 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
651 if(cmSourceFile
* rsf
= sf
->RealSourceFile
)
653 return rsf
->GetPropertyAsBool(prop
) ? 1:0;
657 return cmSystemTools::IsOn(cmSourceFileGetProperty(arg
, prop
))? 1:0;
661 void CCONV
cmSourceFileSetProperty(void *arg
,const char *prop
,
664 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
665 if(cmSourceFile
* rsf
= sf
->RealSourceFile
)
667 rsf
->SetProperty(prop
, value
);
671 if(!value
) { value
= "NOTFOUND"; }
672 sf
->Properties
.SetProperty(prop
, value
, cmProperty::SOURCE_FILE
);
676 void CCONV
cmSourceFileAddDepend(void *arg
, const char *depend
)
678 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
679 if(cmSourceFile
* rsf
= sf
->RealSourceFile
)
681 rsf
->AddDepend(depend
);
685 sf
->Depends
.push_back(depend
);
689 void CCONV
cmSourceFileSetName(void *arg
, const char* name
, const char* dir
,
690 int numSourceExtensions
,
691 const char **sourceExtensions
,
692 int numHeaderExtensions
,
693 const char **headerExtensions
)
695 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
696 if(sf
->RealSourceFile
)
698 // SetName is allowed only on temporary source files created by
699 // the command for building and passing to AddSource.
702 std::vector
<std::string
> sourceExts
;
703 std::vector
<std::string
> headerExts
;
705 for (i
= 0; i
< numSourceExtensions
; ++i
)
707 sourceExts
.push_back(sourceExtensions
[i
]);
709 for (i
= 0; i
< numHeaderExtensions
; ++i
)
711 headerExts
.push_back(headerExtensions
[i
]);
714 // Save the original name given.
715 sf
->SourceName
= name
;
717 // Convert the name to a full path in case the given name is a
719 std::string pathname
= cmSystemTools::CollapseFullPath(name
, dir
);
721 // First try and see whether the listed file can be found
722 // as is without extensions added on.
723 std::string hname
= pathname
;
724 if(cmSystemTools::FileExists(hname
.c_str()))
726 sf
->SourceName
= cmSystemTools::GetFilenamePath(name
);
727 if ( sf
->SourceName
.size() > 0 )
729 sf
->SourceName
+= "/";
731 sf
->SourceName
+= cmSystemTools::GetFilenameWithoutLastExtension(name
);
732 std::string::size_type pos
= hname
.rfind('.');
733 if(pos
!= std::string::npos
)
735 sf
->SourceExtension
= hname
.substr(pos
+1, hname
.size()-pos
);
736 if ( cmSystemTools::FileIsFullPath(name
) )
738 std::string::size_type pos2
= hname
.rfind('/');
739 if(pos2
!= std::string::npos
)
741 sf
->SourceName
= hname
.substr(pos2
+1, pos
- pos2
-1);
746 sf
->FullPath
= hname
;
750 // Next, try the various source extensions
751 for( std::vector
<std::string
>::const_iterator ext
= sourceExts
.begin();
752 ext
!= sourceExts
.end(); ++ext
)
757 if(cmSystemTools::FileExists(hname
.c_str()))
759 sf
->SourceExtension
= *ext
;
760 sf
->FullPath
= hname
;
765 // Finally, try the various header extensions
766 for( std::vector
<std::string
>::const_iterator ext
= headerExts
.begin();
767 ext
!= headerExts
.end(); ++ext
)
772 if(cmSystemTools::FileExists(hname
.c_str()))
774 sf
->SourceExtension
= *ext
;
775 sf
->FullPath
= hname
;
781 e
<< "Cannot find source file \"" << pathname
<< "\"";
782 e
<< "\n\nTried extensions";
783 for( std::vector
<std::string
>::const_iterator ext
= sourceExts
.begin();
784 ext
!= sourceExts
.end(); ++ext
)
788 for( std::vector
<std::string
>::const_iterator ext
= headerExts
.begin();
789 ext
!= headerExts
.end(); ++ext
)
793 cmSystemTools::Error(e
.str().c_str());
797 void CCONV
cmSourceFileSetName2(void *arg
, const char* name
, const char* dir
,
798 const char *ext
, int headerFileOnly
)
800 cmCPluginAPISourceFile
* sf
= static_cast<cmCPluginAPISourceFile
*>(arg
);
801 if(sf
->RealSourceFile
)
803 // SetName is allowed only on temporary source files created by
804 // the command for building and passing to AddSource.
808 // Implement the old SetName method code here.
811 sf
->Properties
.SetProperty("HEADER_FILE_ONLY", "1",
812 cmProperty::SOURCE_FILE
);
814 sf
->SourceName
= name
;
815 std::string fname
= sf
->SourceName
;
816 if(ext
&& strlen(ext
))
821 sf
->FullPath
= cmSystemTools::CollapseFullPath(fname
.c_str(), dir
);
822 cmSystemTools::ConvertToUnixSlashes(sf
->FullPath
);
823 sf
->SourceExtension
= ext
;
826 char * CCONV
cmGetFilenameWithoutExtension(const char *name
)
828 std::string sres
= cmSystemTools::GetFilenameWithoutExtension(name
);
829 char *result
= (char *)malloc(sres
.size()+1);
830 strcpy(result
,sres
.c_str());
834 char * CCONV
cmGetFilenamePath(const char *name
)
836 std::string sres
= cmSystemTools::GetFilenamePath(name
);
837 char *result
= (char *)malloc(sres
.size()+1);
838 strcpy(result
,sres
.c_str());
842 char * CCONV
cmCapitalized(const char *name
)
844 std::string sres
= cmSystemTools::Capitalized(name
);
845 char *result
= (char *)malloc(sres
.size()+1);
846 strcpy(result
,sres
.c_str());
850 void CCONV
cmCopyFileIfDifferent(const char *name1
, const char *name2
)
852 cmSystemTools::CopyFileIfDifferent(name1
,name2
);
855 void CCONV
cmRemoveFile(const char *name
)
857 cmSystemTools::RemoveFile(name
);
860 void CCONV
cmDisplayStatus(void *arg
, const char* message
)
862 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
863 mf
->DisplayStatus(message
, -1);
866 void CCONV
cmFree(void *data
)
871 void CCONV
DefineSourceFileProperty (void *arg
, const char *name
,
872 const char *briefDocs
,
873 const char *longDocs
,
876 cmMakefile
*mf
= static_cast<cmMakefile
*>(arg
);
877 mf
->GetCMakeInstance()->DefineProperty(name
,cmProperty::SOURCE_FILE
,
882 } // close the extern "C" scope
884 cmCAPI cmStaticCAPI
=
887 cmGetTotalArgumentSize
,
891 cmAddCacheDefinition
,
897 cmAddLinkDirectoryForTarget
,
898 cmAddLinkLibraryForTarget
,
902 cmExpandSourceListArguments
,
903 cmExpandVariablesInString
,
904 cmGetCacheMajorVersion
,
905 cmGetCacheMinorVersion
,
906 cmGetCurrentDirectory
,
907 cmGetCurrentOutputDirectory
,
910 cmGetHomeOutputDirectory
,
915 cmGetStartOutputDirectory
,
922 cmSourceFileAddDepend
,
923 cmSourceFileGetProperty
,
924 cmSourceFileGetPropertyAsBool
,
925 cmSourceFileGetSourceName
,
926 cmSourceFileGetFullPath
,
928 cmSourceFileSetName2
,
929 cmSourceFileSetProperty
,
932 cmCopyFileIfDifferent
,
933 cmGetFilenameWithoutExtension
,
938 cmAddCustomCommandToOutput
,
939 cmAddCustomCommandToTarget
,
941 cmCreateNewSourceFile
,
942 DefineSourceFileProperty
,