Fix dependency version under GCC 8

This commit is contained in:
Martchus 2018-05-08 00:35:35 +02:00
parent a4435bbcf3
commit f0b777207e
3 changed files with 12 additions and 6 deletions

View File

@ -407,7 +407,12 @@ const char *applicationVersion = nullptr;
/// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()).
const char *applicationUrl = nullptr;
/// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()).
/// \deprecated Not used anymore. Use dependencyVersions2 instead.
std::initializer_list<const char *> dependencyVersions;
/// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()).
std::vector<const char *> dependencyVersions2;
// TODO v5 use a struct for these properties
/*!
* \brief Specifies a function quit the application.
@ -772,18 +777,18 @@ void ArgumentParser::printHelp(ostream &os) const
if (applicationVersion && *applicationVersion) {
os << "version " << applicationVersion;
}
if (dependencyVersions.size()) {
if (dependencyVersions2.size()) {
if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion)) {
os << '\n';
EscapeCodes::setStyle(os);
}
auto i = dependencyVersions.begin(), end = dependencyVersions.end();
auto i = dependencyVersions2.begin(), end = dependencyVersions2.end();
os << "Linked against: " << *i;
for (++i; i != end; ++i) {
os << ',' << ' ' << *i;
}
}
if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions.size()) {
if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions2.size()) {
os << '\n' << '\n';
}
EscapeCodes::setStyle(os);

View File

@ -22,6 +22,7 @@ CPP_UTILITIES_EXPORT extern const char *applicationAuthor;
CPP_UTILITIES_EXPORT extern const char *applicationVersion;
CPP_UTILITIES_EXPORT extern const char *applicationUrl;
CPP_UTILITIES_EXPORT extern std::initializer_list<const char *> dependencyVersions;
CPP_UTILITIES_EXPORT extern std::vector<const char *> dependencyVersions2;
/*!
* \def SET_DEPENDENCY_INFO
@ -30,9 +31,9 @@ CPP_UTILITIES_EXPORT extern std::initializer_list<const char *> dependencyVersio
* \remarks Reads those data from the config header so "config.h" must be included.
*/
#ifndef APP_STATICALLY_LINKED
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions = DEPENCENCY_VERSIONS
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions2 = DEPENCENCY_VERSIONS
#else
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions = STATIC_DEPENCENCY_VERSIONS
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions2 = STATIC_DEPENCENCY_VERSIONS
#endif
/*!

View File

@ -731,7 +731,7 @@ void ArgumentParserTests::testHelp()
parser.addMainArgument(&verboseArg);
parser.addMainArgument(&filesArg);
parser.addMainArgument(&envArg);
dependencyVersions = { "somelib", "some other lib" };
dependencyVersions2 = { "somelib", "some other lib" };
// parse args and assert output
const char *const argv[] = { "app", "-h" };