ENH: add suport for semi-colon separated list variables

This commit is contained in:
Bill Hoffman 2002-03-06 10:10:46 -05:00
parent 4651dbcfc6
commit 8aa3c35dad
5 changed files with 68 additions and 16 deletions

View File

@ -17,13 +17,15 @@
#include "cmLinkLibrariesCommand.h"
// cmLinkLibrariesCommand
bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& argsIn)
{
if(args.size() < 1 )
if(argsIn.size() < 1 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args;
cmSystemTools::ExpandListArguments(argsIn, args);
// add libraries, nothe that there is an optional prefix
// of debug and optimized than can be used
for(std::vector<std::string>::const_iterator i = args.begin();

View File

@ -40,9 +40,17 @@ void cmMSDotNETGenerator::GenerateMakefile()
while(endpos != std::string::npos)
{
endpos = configTypes.find(' ', start);
std::string config;
std::string::size_type len;
if(endpos != std::string::npos)
{
std::string config = configTypes.substr(start, endpos - start);
len = endpos - start;
}
else
{
len = configTypes.size() - start;
}
config = configTypes.substr(start, len);
if(config == "Debug" || config == "Release" ||
config == "MinSizeRel" || config == "RelWithDebInfo")
{
@ -54,7 +62,6 @@ void cmMSDotNETGenerator::GenerateMakefile()
config.c_str(),
" (Valid types are Debug,Release,MinSizeRel,RelWithDebInfo)");
}
}
start = endpos+1;
}
if(m_Configurations.size() == 0)

View File

@ -1474,3 +1474,37 @@ void cmSystemTools::GlobDirs(const char *fullPath,
}
}
}
void cmSystemTools::ExpandListArguments(std::vector<std::string> const& arguments,
std::vector<std::string>& newargs)
{
std::vector<std::string>::const_iterator i;
for(i = arguments.begin();i != arguments.end(); ++i)
{
if(i->find(';') != std::string::npos)
{
std::string::size_type start = 0;
std::string::size_type endpos = 0;
while(endpos != std::string::npos)
{
endpos = i->find(';', start);
std::string::size_type len;
if(endpos != std::string::npos)
{
len = endpos - start;
}
else
{
len = i->size()-start;
}
newargs.push_back(i->substr(start, len));
start = endpos+1;
}
}
else
{
newargs.push_back(*i);
}
}
}

View File

@ -43,6 +43,13 @@ public:
const char* replace,
const char* with);
/** Expand out any arguements in the vector that have ; separated
* strings into multiple arguements. A new vector is created
* containing the expanded versions of all arguments in argsIn.
*/
static void ExpandListArguments(std::vector<std::string> const& argsIn,
std::vector<std::string>& argsOut);
/**
* Look for and replace registry values in a string
*/

View File

@ -17,13 +17,15 @@
#include "cmTargetLinkLibrariesCommand.h"
// cmTargetLinkLibrariesCommand
bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& argsIn)
{
if(args.size() < 2)
if(argsIn.size() < 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args;
cmSystemTools::ExpandListArguments(argsIn, args);
// add libraries, nothe that there is an optional prefix
// of debug and optimized than can be used
std::vector<std::string>::const_iterator i = args.begin();