From 8aa3c35dadb67d63873d44a9ef55391e419376a1 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 6 Mar 2002 10:10:46 -0500 Subject: [PATCH] ENH: add suport for semi-colon separated list variables --- Source/cmLinkLibrariesCommand.cxx | 6 +++-- Source/cmMSDotNETGenerator.cxx | 31 +++++++++++++--------- Source/cmSystemTools.cxx | 34 +++++++++++++++++++++++++ Source/cmSystemTools.h | 7 +++++ Source/cmTargetLinkLibrariesCommand.cxx | 6 +++-- 5 files changed, 68 insertions(+), 16 deletions(-) diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index e3d7453ca..1cc8b173e 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -17,13 +17,15 @@ #include "cmLinkLibrariesCommand.h" // cmLinkLibrariesCommand -bool cmLinkLibrariesCommand::InitialPass(std::vector const& args) +bool cmLinkLibrariesCommand::InitialPass(std::vector const& argsIn) { - if(args.size() < 1 ) + if(argsIn.size() < 1 ) { this->SetError("called with incorrect number of arguments"); return false; } + std::vector 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::const_iterator i = args.begin(); diff --git a/Source/cmMSDotNETGenerator.cxx b/Source/cmMSDotNETGenerator.cxx index 1e99fac4b..fad881707 100644 --- a/Source/cmMSDotNETGenerator.cxx +++ b/Source/cmMSDotNETGenerator.cxx @@ -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; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9893b6400..a7c68d329 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1474,3 +1474,37 @@ void cmSystemTools::GlobDirs(const char *fullPath, } } } + + +void cmSystemTools::ExpandListArguments(std::vector const& arguments, + std::vector& newargs) +{ + std::vector::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); + } + } +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index a48ea1bf3..d9e4796f5 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -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 const& argsIn, + std::vector& argsOut); + /** * Look for and replace registry values in a string */ diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 20c4efe13..50396e549 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -17,13 +17,15 @@ #include "cmTargetLinkLibrariesCommand.h" // cmTargetLinkLibrariesCommand -bool cmTargetLinkLibrariesCommand::InitialPass(std::vector const& args) +bool cmTargetLinkLibrariesCommand::InitialPass(std::vector const& argsIn) { - if(args.size() < 2) + if(argsIn.size() < 2) { this->SetError("called with incorrect number of arguments"); return false; } + std::vector args; + cmSystemTools::ExpandListArguments(argsIn, args); // add libraries, nothe that there is an optional prefix // of debug and optimized than can be used std::vector::const_iterator i = args.begin();