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,20 +40,27 @@ 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);
if(config == "Debug" || config == "Release" ||
config == "MinSizeRel" || config == "RelWithDebInfo")
{
m_Configurations.push_back(config);
}
else
{
cmSystemTools::Error("Invalid configuration type in CMAKE_CONFIGURATION_TYPES: ",
config.c_str(),
" (Valid types are Debug,Release,MinSizeRel,RelWithDebInfo)");
}
len = endpos - start;
}
else
{
len = configTypes.size() - start;
}
config = configTypes.substr(start, len);
if(config == "Debug" || config == "Release" ||
config == "MinSizeRel" || config == "RelWithDebInfo")
{
m_Configurations.push_back(config);
}
else
{
cmSystemTools::Error("Invalid configuration type in CMAKE_CONFIGURATION_TYPES: ",
config.c_str(),
" (Valid types are Debug,Release,MinSizeRel,RelWithDebInfo)");
}
start = endpos+1;
}

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();