2002-08-21 19:54:06 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2002-08-21 19:54:06 +04:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2002-08-21 19:54:06 +04:00
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
2002-08-21 19:54:06 +04:00
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
2006-03-10 21:06:26 +03:00
|
|
|
/*
|
2002-08-21 19:54:06 +04:00
|
|
|
this file contains the implementation of the C API to CMake. Generally
|
|
|
|
these routines just manipulate arguments and then call the associated
|
|
|
|
methods on the CMake classes. */
|
|
|
|
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmCPluginAPI.h"
|
2006-11-29 23:59:16 +03:00
|
|
|
#include "cmVersion.h"
|
2002-08-21 19:54:06 +04:00
|
|
|
|
2004-02-22 21:14:59 +03:00
|
|
|
#include "cmSourceFile.h"
|
|
|
|
|
2006-08-01 22:31:24 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef __QNX__
|
|
|
|
# include <malloc.h> /* for malloc/free on QNX */
|
|
|
|
#endif
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
extern "C"
|
2002-08-29 17:45:34 +04:00
|
|
|
{
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV *cmGetClientData(void *info)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
return ((cmLoadedCommandInfo *)info)->ClientData;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmSetClientData(void *info, void *cd)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
((cmLoadedCommandInfo *)info)->ClientData = cd;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmSetError(void *info, const char *err)
|
2002-10-08 23:55:04 +04:00
|
|
|
{
|
|
|
|
if (((cmLoadedCommandInfo *)info)->Error)
|
|
|
|
{
|
|
|
|
free(((cmLoadedCommandInfo *)info)->Error);
|
|
|
|
}
|
|
|
|
((cmLoadedCommandInfo *)info)->Error = strdup(err);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
unsigned int CCONV cmGetCacheMajorVersion(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2002-08-28 22:51:10 +04:00
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetCacheMajorVersion();
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
unsigned int CCONV cmGetCacheMinorVersion(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2002-08-28 22:51:10 +04:00
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetCacheMinorVersion();
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
unsigned int CCONV cmGetMajorVersion(void *)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2006-11-29 23:59:16 +03:00
|
|
|
return cmVersion::GetMajorVersion();
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
unsigned int CCONV cmGetMinorVersion(void *)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2006-11-29 23:59:16 +03:00
|
|
|
return cmVersion::GetMinorVersion();
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddDefinition(void *arg, const char* name, const char* value)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
mf->AddDefinition(name,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a definition to this makefile and the global cmake cache. */
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmAddCacheDefinition(void *arg, const char* name,
|
|
|
|
const char* value, const char* doc, int type)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-08-21 19:54:06 +04:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CM_CACHE_BOOL:
|
|
|
|
mf->AddCacheDefinition(name,value,doc,
|
2002-08-21 21:16:07 +04:00
|
|
|
cmCacheManager::BOOL);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_CACHE_PATH:
|
|
|
|
mf->AddCacheDefinition(name,value,doc,
|
2002-08-21 21:16:07 +04:00
|
|
|
cmCacheManager::PATH);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_CACHE_FILEPATH:
|
|
|
|
mf->AddCacheDefinition(name,value,doc,
|
2002-08-21 21:16:07 +04:00
|
|
|
cmCacheManager::FILEPATH);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_CACHE_STRING:
|
|
|
|
mf->AddCacheDefinition(name,value,doc,
|
2002-08-21 21:16:07 +04:00
|
|
|
cmCacheManager::STRING);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_CACHE_INTERNAL:
|
|
|
|
mf->AddCacheDefinition(name,value,doc,
|
2002-08-21 21:16:07 +04:00
|
|
|
cmCacheManager::INTERNAL);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_CACHE_STATIC:
|
|
|
|
mf->AddCacheDefinition(name,value,doc,
|
2002-08-21 21:16:07 +04:00
|
|
|
cmCacheManager::STATIC);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetProjectName(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetProjectName();
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetHomeDirectory(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetHomeDirectory();
|
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetHomeOutputDirectory(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetHomeOutputDirectory();
|
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetStartDirectory(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetStartDirectory();
|
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetStartOutputDirectory(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetStartOutputDirectory();
|
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
const char* CCONV cmGetCurrentDirectory(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetCurrentDirectory();
|
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetCurrentOutputDirectory(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetCurrentOutputDirectory();
|
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
const char* CCONV cmGetDefinition(void *arg,const char*def)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return mf->GetDefinition(def);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
int CCONV cmIsOn(void *arg, const char* name)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return static_cast<int>(mf->IsOn(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Check if a command exists. */
|
2006-01-17 18:21:45 +03:00
|
|
|
int CCONV cmCommandExists(void *arg, const char* name)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return static_cast<int>(mf->CommandExists(name));
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddDefineFlag(void *arg, const char* definition)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
mf->AddDefineFlag(definition);
|
|
|
|
}
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmAddLinkDirectoryForTarget(void *arg, const char *tgt,
|
|
|
|
const char* d)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
mf->AddLinkDirectoryForTarget(tgt,d);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmAddExecutable(void *arg, const char *exename,
|
2002-08-21 19:54:06 +04:00
|
|
|
int numSrcs, const char **srcs, int win32)
|
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
std::vector<std::string> srcs2;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < numSrcs; ++i)
|
|
|
|
{
|
|
|
|
srcs2.push_back(srcs[i]);
|
|
|
|
}
|
2004-02-29 02:59:19 +03:00
|
|
|
cmTarget* tg = mf->AddExecutable(exename, srcs2);
|
|
|
|
if ( win32 )
|
|
|
|
{
|
|
|
|
tg->SetProperty("WIN32_EXECUTABLE", "ON");
|
|
|
|
}
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddUtilityCommand(void *arg, const char* utilityName,
|
2002-08-21 19:54:06 +04:00
|
|
|
const char* command,
|
|
|
|
const char* arguments,
|
|
|
|
int all,
|
|
|
|
int numDepends,
|
|
|
|
const char **depends,
|
2006-09-28 21:55:26 +04:00
|
|
|
int,
|
|
|
|
const char **)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
// Get the makefile instance. Perform an extra variable expansion
|
|
|
|
// now because the API caller expects it.
|
|
|
|
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
|
|
|
|
|
|
|
// Construct the command line for the command.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
std::string expand = command;
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
|
|
|
if(arguments && arguments[0])
|
|
|
|
{
|
|
|
|
// TODO: Parse arguments!
|
|
|
|
expand = arguments;
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
|
|
|
}
|
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
|
|
|
|
// Accumulate the list of dependencies.
|
2002-08-21 19:54:06 +04:00
|
|
|
std::vector<std::string> depends2;
|
2005-02-22 18:32:44 +03:00
|
|
|
for(int i = 0; i < numDepends; ++i)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = depends[i];
|
|
|
|
depends2.push_back(mf->ExpandVariablesInString(expand));
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Pass the call to the makefile instance.
|
|
|
|
mf->AddUtilityCommand(utilityName, (all ? true : false),
|
2006-09-28 21:55:26 +04:00
|
|
|
0, depends2, commandLines);
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddCustomCommand(void *arg, const char* source,
|
2002-08-21 19:54:06 +04:00
|
|
|
const char* command,
|
|
|
|
int numArgs, const char **args,
|
|
|
|
int numDepends, const char **depends,
|
|
|
|
int numOutputs, const char **outputs,
|
|
|
|
const char *target)
|
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
// Get the makefile instance. Perform an extra variable expansion
|
|
|
|
// now because the API caller expects it.
|
|
|
|
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
|
|
|
|
|
|
|
// Construct the command line for the command.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
std::string expand = command;
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
|
|
|
for(int i=0; i < numArgs; ++i)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = args[i];
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
|
|
|
|
// Accumulate the list of dependencies.
|
2002-08-21 19:54:06 +04:00
|
|
|
std::vector<std::string> depends2;
|
2005-02-22 18:32:44 +03:00
|
|
|
for(int i = 0; i < numDepends; ++i)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = depends[i];
|
|
|
|
depends2.push_back(mf->ExpandVariablesInString(expand));
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Accumulate the list of outputs.
|
2002-08-21 19:54:06 +04:00
|
|
|
std::vector<std::string> outputs2;
|
2005-02-22 18:32:44 +03:00
|
|
|
for(int i = 0; i < numOutputs; ++i)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = outputs[i];
|
|
|
|
outputs2.push_back(mf->ExpandVariablesInString(expand));
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Pass the call to the makefile instance.
|
|
|
|
const char* no_comment = 0;
|
|
|
|
mf->AddCustomCommandOldStyle(target, outputs2, depends2, source,
|
|
|
|
commandLines, no_comment);
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddCustomCommandToOutput(void *arg, const char* output,
|
2003-06-03 18:30:23 +04:00
|
|
|
const char* command,
|
|
|
|
int numArgs, const char **args,
|
|
|
|
const char* main_dependency,
|
|
|
|
int numDepends, const char **depends)
|
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
// Get the makefile instance. Perform an extra variable expansion
|
|
|
|
// now because the API caller expects it.
|
|
|
|
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
|
|
|
|
|
|
|
// Construct the command line for the command.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
std::string expand = command;
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
|
|
|
for(int i=0; i < numArgs; ++i)
|
2003-06-03 18:30:23 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = args[i];
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
|
|
|
|
// Accumulate the list of dependencies.
|
2003-06-03 18:30:23 +04:00
|
|
|
std::vector<std::string> depends2;
|
2005-02-22 18:32:44 +03:00
|
|
|
for(int i = 0; i < numDepends; ++i)
|
2003-06-03 18:30:23 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = depends[i];
|
|
|
|
depends2.push_back(mf->ExpandVariablesInString(expand));
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Pass the call to the makefile instance.
|
|
|
|
const char* no_comment = 0;
|
2006-02-08 18:58:36 +03:00
|
|
|
const char* no_working_dir = 0;
|
2005-02-22 18:32:44 +03:00
|
|
|
mf->AddCustomCommandToOutput(output, depends2, main_dependency,
|
2006-02-08 18:58:36 +03:00
|
|
|
commandLines, no_comment, no_working_dir);
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
|
2003-06-03 18:30:23 +04:00
|
|
|
const char* command,
|
|
|
|
int numArgs, const char **args,
|
|
|
|
int commandType)
|
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
// Get the makefile instance.
|
|
|
|
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
|
|
|
|
|
|
|
// Construct the command line for the command. Perform an extra
|
|
|
|
// variable expansion now because the API caller expects it.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
std::string expand = command;
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
|
|
|
for(int i=0; i < numArgs; ++i)
|
2003-06-03 18:30:23 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
expand = args[i];
|
|
|
|
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
|
|
|
|
// Select the command type.
|
|
|
|
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
|
2003-06-03 18:30:23 +04:00
|
|
|
switch (commandType)
|
|
|
|
{
|
|
|
|
case CM_PRE_BUILD:
|
2005-02-22 18:32:44 +03:00
|
|
|
cctype = cmTarget::PRE_BUILD;
|
2003-06-03 18:30:23 +04:00
|
|
|
break;
|
|
|
|
case CM_PRE_LINK:
|
2005-02-22 18:32:44 +03:00
|
|
|
cctype = cmTarget::PRE_LINK;
|
2003-06-03 18:30:23 +04:00
|
|
|
break;
|
|
|
|
case CM_POST_BUILD:
|
2005-02-22 18:32:44 +03:00
|
|
|
cctype = cmTarget::POST_BUILD;
|
2003-06-03 18:30:23 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Pass the call to the makefile instance.
|
|
|
|
std::vector<std::string> no_depends;
|
|
|
|
const char* no_comment = 0;
|
2006-02-08 18:58:36 +03:00
|
|
|
const char* no_working_dir = 0;
|
2005-02-22 18:32:44 +03:00
|
|
|
mf->AddCustomCommandToTarget(target, no_depends, commandLines,
|
2006-02-08 18:58:36 +03:00
|
|
|
cctype, no_comment, no_working_dir);
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2002-08-21 19:54:06 +04:00
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt,
|
|
|
|
const char*value, int libtype)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-08-21 19:54:06 +04:00
|
|
|
switch (libtype)
|
|
|
|
{
|
|
|
|
case CM_LIBRARY_GENERAL:
|
2002-08-21 21:16:07 +04:00
|
|
|
mf->AddLinkLibraryForTarget(tgt,value, cmTarget::GENERAL);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_LIBRARY_DEBUG:
|
2002-08-21 21:16:07 +04:00
|
|
|
mf->AddLinkLibraryForTarget(tgt,value, cmTarget::DEBUG);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
case CM_LIBRARY_OPTIMIZED:
|
2002-08-21 21:16:07 +04:00
|
|
|
mf->AddLinkLibraryForTarget(tgt,value, cmTarget::OPTIMIZED);
|
2002-08-21 19:54:06 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmAddLibrary(void *arg, const char *libname, int shared,
|
2002-08-21 19:54:06 +04:00
|
|
|
int numSrcs, const char **srcs)
|
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
std::vector<std::string> srcs2;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < numSrcs; ++i)
|
|
|
|
{
|
|
|
|
srcs2.push_back(srcs[i]);
|
|
|
|
}
|
|
|
|
mf->AddLibrary(libname, (shared ? true : false), srcs2);
|
|
|
|
}
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
char CCONV *cmExpandVariablesInString(void *arg, const char *source,
|
2002-08-21 19:54:06 +04:00
|
|
|
int escapeQuotes, int atOnly)
|
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
2002-08-21 21:16:07 +04:00
|
|
|
std::string barf = source;
|
2006-03-10 21:06:26 +03:00
|
|
|
std::string result =
|
|
|
|
mf->ExpandVariablesInString(barf,
|
2002-08-21 19:54:06 +04:00
|
|
|
(escapeQuotes ? true : false),
|
|
|
|
(atOnly ? true : false));
|
|
|
|
char *res = static_cast<char *>(malloc(result.size() + 1));
|
|
|
|
if (result.size())
|
|
|
|
{
|
|
|
|
strcpy(res,result.c_str());
|
|
|
|
}
|
|
|
|
res[result.size()] = '\0';
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
int CCONV cmExecuteCommand(void *arg, const char *name,
|
2002-12-18 01:05:59 +03:00
|
|
|
int numArgs, const char **args)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
2002-12-12 02:13:33 +03:00
|
|
|
cmListFileFunction lff;
|
2006-03-15 19:02:08 +03:00
|
|
|
lff.Name = name;
|
2002-12-12 02:13:33 +03:00
|
|
|
for(int i = 0; i < numArgs; ++i)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
2002-12-12 02:13:33 +03:00
|
|
|
// Assume all arguments are quoted.
|
2006-03-15 19:02:08 +03:00
|
|
|
lff.Arguments.push_back(cmListFileArgument(args[i], true,
|
|
|
|
"[CMake-Plugin]", 0));
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
2002-12-18 01:05:59 +03:00
|
|
|
return mf->ExecuteCommand(lff);
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmExpandSourceListArguments(void *arg,
|
2002-08-21 19:54:06 +04:00
|
|
|
int numArgs,
|
|
|
|
const char **args,
|
|
|
|
int *resArgc,
|
|
|
|
char ***resArgv,
|
|
|
|
unsigned int startArgumentIndex)
|
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
std::vector<std::string> result;
|
|
|
|
std::vector<std::string> args2;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < numArgs; ++i)
|
|
|
|
{
|
|
|
|
args2.push_back(args[i]);
|
|
|
|
}
|
|
|
|
mf->ExpandSourceListArguments(args2, result, startArgumentIndex);
|
2002-08-23 23:13:49 +04:00
|
|
|
int resargc = static_cast<int>(result.size());
|
2002-09-10 23:39:18 +04:00
|
|
|
char **resargv = 0;
|
2002-08-21 19:54:06 +04:00
|
|
|
if (resargc)
|
|
|
|
{
|
|
|
|
resargv = (char **)malloc(resargc*sizeof(char *));
|
|
|
|
}
|
|
|
|
for (i = 0; i < resargc; ++i)
|
|
|
|
{
|
|
|
|
resargv[i] = strdup(result[i].c_str());
|
|
|
|
}
|
|
|
|
*resArgc = resargc;
|
|
|
|
*resArgv = resargv;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmFreeArguments(int argc, char **argv)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < argc; ++i)
|
|
|
|
{
|
|
|
|
free(argv[i]);
|
|
|
|
}
|
|
|
|
if (argv)
|
|
|
|
{
|
|
|
|
free(argv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
int CCONV cmGetTotalArgumentSize(int argc, char **argv)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int result = 0;
|
|
|
|
for (i = 0; i < argc; ++i)
|
|
|
|
{
|
|
|
|
if (argv[i])
|
|
|
|
{
|
2002-08-23 23:13:49 +04:00
|
|
|
result = result + static_cast<int>(strlen(argv[i]));
|
2002-08-21 19:54:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV *cmGetSource(void *arg, const char *name)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
return (void *)mf->GetSource(name);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void * CCONV cmAddSource(void *arg, void *arg2)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg2);
|
|
|
|
return (void *)mf->AddSource(*sf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void * CCONV cmCreateSourceFile()
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
return (void *)(new cmSourceFile);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmDestroySourceFile(void *arg)
|
2002-12-11 22:16:55 +03:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
delete sf;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
const char * CCONV cmSourceFileGetSourceName(void *arg)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
return sf->GetSourceName().c_str();
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
const char * CCONV cmSourceFileGetFullPath(void *arg)
|
2002-11-14 19:03:08 +03:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
return sf->GetFullPath().c_str();
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
const char * CCONV cmSourceFileGetProperty(void *arg,const char *prop)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
return sf->GetProperty(prop);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
int CCONV cmSourceFileGetPropertyAsBool(void *arg,const char *prop)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
return (sf->GetPropertyAsBool(prop) ? 1: 0);
|
|
|
|
}
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmSourceFileSetProperty(void *arg,const char *prop,
|
|
|
|
const char *val)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
sf->SetProperty(prop,val);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmSourceFileAddDepend(void *arg, const char *depend)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
sf->GetDepends().push_back(depend);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
|
2002-08-21 19:54:06 +04:00
|
|
|
int numSourceExtensions,
|
|
|
|
const char **sourceExtensions,
|
|
|
|
int numHeaderExtensions,
|
|
|
|
const char **headerExtensions)
|
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
std::vector<std::string> srcs;
|
|
|
|
std::vector<std::string> hdrs;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < numSourceExtensions; ++i)
|
|
|
|
{
|
|
|
|
srcs.push_back(sourceExtensions[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < numHeaderExtensions; ++i)
|
|
|
|
{
|
|
|
|
hdrs.push_back(headerExtensions[i]);
|
|
|
|
}
|
|
|
|
sf->SetName(name,dir, srcs, hdrs);
|
|
|
|
}
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir,
|
2002-08-21 19:54:06 +04:00
|
|
|
const char *ext, int headerFileOnly)
|
|
|
|
{
|
|
|
|
cmSourceFile *sf = static_cast<cmSourceFile *>(arg);
|
|
|
|
sf->SetName(name,dir,ext,(headerFileOnly ? true : false));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
char * CCONV cmGetFilenameWithoutExtension(const char *name)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
|
2006-03-10 21:06:26 +03:00
|
|
|
char *result = (char *)malloc(sres.size()+1);
|
2002-08-21 19:54:06 +04:00
|
|
|
strcpy(result,sres.c_str());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
char * CCONV cmGetFilenamePath(const char *name)
|
2002-11-14 19:16:58 +03:00
|
|
|
{
|
|
|
|
std::string sres = cmSystemTools::GetFilenamePath(name);
|
2006-03-10 21:06:26 +03:00
|
|
|
char *result = (char *)malloc(sres.size()+1);
|
2002-11-14 19:16:58 +03:00
|
|
|
strcpy(result,sres.c_str());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
char * CCONV cmCapitalized(const char *name)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
std::string sres = cmSystemTools::Capitalized(name);
|
2006-03-10 21:06:26 +03:00
|
|
|
char *result = (char *)malloc(sres.size()+1);
|
2002-08-21 19:54:06 +04:00
|
|
|
strcpy(result,sres.c_str());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmCopyFileIfDifferent(const char *name1, const char *name2)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSystemTools::CopyFileIfDifferent(name1,name2);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmRemoveFile(const char *name)
|
2002-08-21 19:54:06 +04:00
|
|
|
{
|
|
|
|
cmSystemTools::RemoveFile(name);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmDisplayStatus(void *arg, const char* message)
|
2003-07-22 21:14:55 +04:00
|
|
|
{
|
|
|
|
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
2003-07-22 21:53:06 +04:00
|
|
|
mf->DisplayStatus(message, -1);
|
2003-07-22 21:14:55 +04:00
|
|
|
}
|
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
void CCONV cmFree(void *data)
|
2002-12-11 22:16:55 +03:00
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
2002-08-29 17:45:34 +04:00
|
|
|
} // close the extern "C" scope
|
|
|
|
|
2002-08-26 18:52:04 +04:00
|
|
|
cmCAPI cmStaticCAPI =
|
|
|
|
{
|
|
|
|
cmGetClientData,
|
2002-10-08 23:55:04 +04:00
|
|
|
cmGetTotalArgumentSize,
|
|
|
|
cmFreeArguments,
|
|
|
|
cmSetClientData,
|
|
|
|
cmSetError,
|
|
|
|
cmAddCacheDefinition,
|
|
|
|
cmAddCustomCommand,
|
|
|
|
cmAddDefineFlag,
|
|
|
|
cmAddDefinition,
|
|
|
|
cmAddExecutable,
|
|
|
|
cmAddLibrary,
|
|
|
|
cmAddLinkDirectoryForTarget,
|
|
|
|
cmAddLinkLibraryForTarget,
|
|
|
|
cmAddUtilityCommand,
|
|
|
|
cmCommandExists,
|
|
|
|
cmExecuteCommand,
|
|
|
|
cmExpandSourceListArguments,
|
|
|
|
cmExpandVariablesInString,
|
|
|
|
cmGetCacheMajorVersion,
|
|
|
|
cmGetCacheMinorVersion,
|
|
|
|
cmGetCurrentDirectory,
|
|
|
|
cmGetCurrentOutputDirectory,
|
|
|
|
cmGetDefinition,
|
|
|
|
cmGetHomeDirectory,
|
|
|
|
cmGetHomeOutputDirectory,
|
|
|
|
cmGetMajorVersion,
|
|
|
|
cmGetMinorVersion,
|
|
|
|
cmGetProjectName,
|
|
|
|
cmGetStartDirectory,
|
|
|
|
cmGetStartOutputDirectory,
|
|
|
|
cmIsOn,
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-10-08 23:55:04 +04:00
|
|
|
cmAddSource,
|
|
|
|
cmCreateSourceFile,
|
2002-12-11 22:16:55 +03:00
|
|
|
cmDestroySourceFile,
|
2002-10-08 23:55:04 +04:00
|
|
|
cmGetSource,
|
|
|
|
cmSourceFileAddDepend,
|
|
|
|
cmSourceFileGetProperty,
|
|
|
|
cmSourceFileGetPropertyAsBool,
|
|
|
|
cmSourceFileGetSourceName,
|
2002-11-14 19:03:08 +03:00
|
|
|
cmSourceFileGetFullPath,
|
2002-10-08 23:55:04 +04:00
|
|
|
cmSourceFileSetName,
|
|
|
|
cmSourceFileSetName2,
|
|
|
|
cmSourceFileSetProperty,
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-10-08 23:55:04 +04:00
|
|
|
cmCapitalized,
|
|
|
|
cmCopyFileIfDifferent,
|
|
|
|
cmGetFilenameWithoutExtension,
|
2002-11-14 19:16:58 +03:00
|
|
|
cmGetFilenamePath,
|
2002-10-08 23:55:04 +04:00
|
|
|
cmRemoveFile,
|
2002-12-11 22:16:55 +03:00
|
|
|
cmFree,
|
2003-06-03 18:30:23 +04:00
|
|
|
|
|
|
|
cmAddCustomCommandToOutput,
|
|
|
|
cmAddCustomCommandToTarget,
|
2003-07-23 22:31:30 +04:00
|
|
|
cmDisplayStatus,
|
2002-08-26 18:52:04 +04:00
|
|
|
};
|
|
|
|
|