Brad King | 86578ec | 2016-09-27 15:01:08 -0400 | [diff] [blame] | 1 | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 | file Copyright.txt or https://cmake.org/licensing for details. */ |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 3 | #include "cmIDEOptions.h" |
| 4 | |
NAKAMURA Takumi | 0e58a5e | 2021-11-14 19:58:11 +0900 | [diff] [blame] | 5 | #include <algorithm> |
Rose | 6f4727a | 2021-10-23 11:27:46 -0400 | [diff] [blame] | 6 | #include <cstring> |
Daniel Pfeifer | 66a7099 | 2016-11-25 22:54:58 +0100 | [diff] [blame] | 7 | #include <iterator> |
NAKAMURA Takumi | 0e58a5e | 2021-11-14 19:58:11 +0900 | [diff] [blame] | 8 | #include <utility> |
Kitware Robot | ed98209 | 2019-09-30 10:46:28 -0400 | [diff] [blame] | 9 | |
Marc Chevrier | f7d1260 | 2019-12-09 17:39:29 +0100 | [diff] [blame] | 10 | #include <cmext/algorithm> |
| 11 | |
Kitware Robot | ed98209 | 2019-09-30 10:46:28 -0400 | [diff] [blame] | 12 | #include "cmsys/String.h" |
| 13 | |
Daniel Pfeifer | 66a7099 | 2016-11-25 22:54:58 +0100 | [diff] [blame] | 14 | #include "cmIDEFlagTable.h" |
Marc Chevrier | 2413041 | 2023-04-25 19:54:23 +0200 | [diff] [blame] | 15 | #include "cmList.h" |
Sebastian Holtermann | f4f3c68 | 2019-08-11 11:56:59 +0200 | [diff] [blame] | 16 | #include "cmStringAlgorithms.h" |
Brad King | 4ca9df8 | 2016-01-08 14:30:06 -0500 | [diff] [blame] | 17 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 18 | cmIDEOptions::cmIDEOptions() |
| 19 | { |
| 20 | this->DoingDefine = false; |
| 21 | this->AllowDefine = true; |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 22 | this->DoingInclude = false; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 23 | this->AllowSlash = false; |
Ben Boeckel | 1b929ba | 2022-11-22 13:51:48 -0500 | [diff] [blame] | 24 | this->DoingFollowing = nullptr; |
Ben Boeckel | 1f893e5 | 2022-11-23 08:31:18 -0500 | [diff] [blame] | 25 | for (auto& flag : this->FlagTable) { |
| 26 | flag = nullptr; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 27 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 28 | } |
| 29 | |
Ben Boeckel | 83d685e | 2022-11-22 13:39:20 -0500 | [diff] [blame] | 30 | cmIDEOptions::~cmIDEOptions() = default; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 31 | |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 32 | void cmIDEOptions::HandleFlag(std::string const& flag) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 33 | { |
| 34 | // If the last option was -D then this option is the definition. |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 35 | if (this->DoingDefine) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 36 | this->DoingDefine = false; |
| 37 | this->Defines.push_back(flag); |
| 38 | return; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 39 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 40 | |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 41 | // If the last option was -I then this option is the include directory. |
| 42 | if (this->DoingInclude) { |
| 43 | this->DoingInclude = false; |
| 44 | this->Includes.push_back(flag); |
| 45 | return; |
| 46 | } |
| 47 | |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 48 | // If the last option expected a following value, this is it. |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 49 | if (this->DoingFollowing) { |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 50 | this->FlagMapUpdate(this->DoingFollowing, flag); |
Ben Boeckel | 1b929ba | 2022-11-22 13:51:48 -0500 | [diff] [blame] | 51 | this->DoingFollowing = nullptr; |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 52 | return; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 53 | } |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 54 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 55 | // Look for known arguments. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 56 | size_t len = flag.length(); |
| 57 | if (len > 0 && (flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 58 | // Look for preprocessor definitions. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 59 | if (this->AllowDefine && len > 1 && flag[1] == 'D') { |
| 60 | if (len <= 2) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 61 | // The next argument will have the definition. |
| 62 | this->DoingDefine = true; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 63 | } else { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 64 | // Store this definition. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 65 | this->Defines.push_back(flag.substr(2)); |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 66 | } |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 67 | return; |
| 68 | } |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 69 | // Look for include directory. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 70 | if (this->AllowInclude && len > 1 && flag[1] == 'I') { |
| 71 | if (len <= 2) { |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 72 | // The next argument will have the include directory. |
| 73 | this->DoingInclude = true; |
| 74 | } else { |
| 75 | // Store this include directory. |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 76 | this->Includes.push_back(flag.substr(2)); |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 77 | } |
| 78 | return; |
| 79 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 80 | |
| 81 | // Look through the available flag tables. |
| 82 | bool flag_handled = false; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 83 | for (int i = 0; i < FlagTableCount && this->FlagTable[i]; ++i) { |
| 84 | if (this->CheckFlagTable(this->FlagTable[i], flag, flag_handled)) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 85 | return; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 89 | // If any map entry handled the flag we are done. |
| 90 | if (flag_handled) { |
| 91 | return; |
| 92 | } |
| 93 | } |
| 94 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 95 | // This option is not known. Store it in the output flags. |
| 96 | this->StoreUnknownFlag(flag); |
| 97 | } |
| 98 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 99 | bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 100 | std::string const& flag, bool& flag_handled) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 101 | { |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 102 | const char* pf = flag.c_str() + 1; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 103 | // Look for an entry in the flag table matching this flag. |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 104 | for (cmIDEFlagTable const* entry = table; !entry->IDEName.empty(); ++entry) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 105 | bool entry_found = false; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 106 | if (entry->special & cmIDEFlagTable::UserValue) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 107 | // This flag table entry accepts a user-specified value. If |
| 108 | // the entry specifies UserRequired we must match only if a |
| 109 | // non-empty value is given. |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 110 | int n = static_cast<int>(entry->commandFlag.length()); |
| 111 | if ((strncmp(pf, entry->commandFlag.c_str(), n) == 0 || |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 112 | (entry->special & cmIDEFlagTable::CaseInsensitive && |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 113 | cmsysString_strncasecmp(pf, entry->commandFlag.c_str(), n))) && |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 114 | (!(entry->special & cmIDEFlagTable::UserRequired) || |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 115 | static_cast<int>(strlen(pf)) > n)) { |
| 116 | this->FlagMapUpdate(entry, std::string(pf + n)); |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 117 | entry_found = true; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 118 | } |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 119 | } else if (strcmp(pf, entry->commandFlag.c_str()) == 0 || |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 120 | (entry->special & cmIDEFlagTable::CaseInsensitive && |
Stephan Szabo | 8279302 | 2018-11-20 10:09:57 -0800 | [diff] [blame] | 121 | cmsysString_strcasecmp(pf, entry->commandFlag.c_str()) == 0)) { |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 122 | if (entry->special & cmIDEFlagTable::UserFollowing) { |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 123 | // This flag expects a value in the following argument. |
| 124 | this->DoingFollowing = entry; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 125 | } else { |
Brad King | 650199e | 2014-04-01 14:56:08 -0400 | [diff] [blame] | 126 | // This flag table entry provides a fixed value. |
| 127 | this->FlagMap[entry->IDEName] = entry->value; |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 128 | } |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 129 | entry_found = true; |
| 130 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 131 | |
| 132 | // If the flag has been handled by an entry not requesting a |
| 133 | // search continuation we are done. |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 134 | if (entry_found && !(entry->special & cmIDEFlagTable::Continue)) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 135 | return true; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 136 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 137 | |
| 138 | // If the entry was found the flag has been handled. |
| 139 | flag_handled = flag_handled || entry_found; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 140 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 141 | |
| 142 | return false; |
| 143 | } |
| 144 | |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 145 | void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry, |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 146 | std::string const& new_value) |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 147 | { |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 148 | if (entry->special & cmIDEFlagTable::UserIgnored) { |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 149 | // Ignore the user-specified value. |
| 150 | this->FlagMap[entry->IDEName] = entry->value; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 151 | } else if (entry->special & cmIDEFlagTable::SemicolonAppendable) { |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 152 | this->FlagMap[entry->IDEName].push_back(new_value); |
Brad King | 3936a28 | 2017-02-15 09:35:36 -0500 | [diff] [blame] | 153 | } else if (entry->special & cmIDEFlagTable::SpaceAppendable) { |
| 154 | this->FlagMap[entry->IDEName].append_with_space(new_value); |
Wil Stark | 8226979 | 2019-02-05 15:12:38 -0800 | [diff] [blame] | 155 | } else if (entry->special & cmIDEFlagTable::CommaAppendable) { |
| 156 | this->FlagMap[entry->IDEName].append_with_comma(new_value); |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 157 | } else { |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 158 | // Use the user-specified value. |
| 159 | this->FlagMap[entry->IDEName] = new_value; |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 160 | } |
Brad King | f2a3dd9 | 2014-04-01 14:54:28 -0400 | [diff] [blame] | 161 | } |
| 162 | |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 163 | void cmIDEOptions::AddDefine(const std::string& def) |
| 164 | { |
| 165 | this->Defines.push_back(def); |
| 166 | } |
| 167 | |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 168 | void cmIDEOptions::AddDefines(std::string const& defines) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 169 | { |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 170 | if (!defines.empty()) { |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 171 | // Expand the list of definitions. |
Sebastian Holtermann | f4f3c68 | 2019-08-11 11:56:59 +0200 | [diff] [blame] | 172 | cmExpandList(defines, this->Defines); |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 173 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 174 | } |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 175 | void cmIDEOptions::AddDefines(const std::vector<std::string>& defines) |
Stephen Kelly | afc9243c | 2013-07-10 15:22:59 +0200 | [diff] [blame] | 176 | { |
Marc Chevrier | f7d1260 | 2019-12-09 17:39:29 +0100 | [diff] [blame] | 177 | cm::append(this->Defines, defines); |
Stephen Kelly | afc9243c | 2013-07-10 15:22:59 +0200 | [diff] [blame] | 178 | } |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 179 | |
Brad King | 8a619e8 | 2017-03-28 12:55:14 -0400 | [diff] [blame] | 180 | std::vector<std::string> const& cmIDEOptions::GetDefines() const |
| 181 | { |
| 182 | return this->Defines; |
| 183 | } |
| 184 | |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 185 | void cmIDEOptions::AddInclude(const std::string& include) |
| 186 | { |
| 187 | this->Includes.push_back(include); |
| 188 | } |
| 189 | |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 190 | void cmIDEOptions::AddIncludes(std::string const& includes) |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 191 | { |
Vitaly Stakhovsky | 8182ebc | 2018-02-26 11:24:45 -0500 | [diff] [blame] | 192 | if (!includes.empty()) { |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 193 | // Expand the list of includes. |
Sebastian Holtermann | f4f3c68 | 2019-08-11 11:56:59 +0200 | [diff] [blame] | 194 | cmExpandList(includes, this->Includes); |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 195 | } |
| 196 | } |
| 197 | void cmIDEOptions::AddIncludes(const std::vector<std::string>& includes) |
| 198 | { |
Marc Chevrier | f7d1260 | 2019-12-09 17:39:29 +0100 | [diff] [blame] | 199 | cm::append(this->Includes, includes); |
Marc Chevrier | 3073bd1 | 2017-12-19 16:03:41 +0100 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | std::vector<std::string> const& cmIDEOptions::GetIncludes() const |
| 203 | { |
| 204 | return this->Includes; |
| 205 | } |
| 206 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 207 | void cmIDEOptions::AddFlag(std::string const& flag, std::string const& value) |
Brad King | 5b85a58 | 2009-07-29 11:29:08 -0400 | [diff] [blame] | 208 | { |
| 209 | this->FlagMap[flag] = value; |
| 210 | } |
David Cole | 98b448e | 2011-02-09 12:59:09 -0500 | [diff] [blame] | 211 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 212 | void cmIDEOptions::AddFlag(std::string const& flag, |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 213 | std::vector<std::string> const& value) |
| 214 | { |
| 215 | this->FlagMap[flag] = value; |
| 216 | } |
| 217 | |
Brad King | 29410df | 2014-07-31 14:02:03 -0400 | [diff] [blame] | 218 | void cmIDEOptions::AppendFlag(std::string const& flag, |
| 219 | std::string const& value) |
| 220 | { |
| 221 | this->FlagMap[flag].push_back(value); |
| 222 | } |
| 223 | |
Brad King | 8410010 | 2014-08-13 13:39:35 -0400 | [diff] [blame] | 224 | void cmIDEOptions::AppendFlag(std::string const& flag, |
| 225 | std::vector<std::string> const& value) |
| 226 | { |
| 227 | FlagValue& fv = this->FlagMap[flag]; |
| 228 | std::copy(value.begin(), value.end(), std::back_inserter(fv)); |
| 229 | } |
| 230 | |
Brad King | 3936a28 | 2017-02-15 09:35:36 -0500 | [diff] [blame] | 231 | void cmIDEOptions::AppendFlagString(std::string const& flag, |
| 232 | std::string const& value) |
| 233 | { |
| 234 | this->FlagMap[flag].append_with_space(value); |
| 235 | } |
| 236 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 237 | void cmIDEOptions::RemoveFlag(std::string const& flag) |
David Cole | 98b448e | 2011-02-09 12:59:09 -0500 | [diff] [blame] | 238 | { |
| 239 | this->FlagMap.erase(flag); |
| 240 | } |
Brad King | c65a2ea | 2012-10-26 10:16:45 -0400 | [diff] [blame] | 241 | |
Brad King | 9633d11 | 2014-08-13 14:07:07 -0400 | [diff] [blame] | 242 | bool cmIDEOptions::HasFlag(std::string const& flag) const |
| 243 | { |
| 244 | return this->FlagMap.find(flag) != this->FlagMap.end(); |
| 245 | } |
| 246 | |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 247 | const char* cmIDEOptions::GetFlag(std::string const& flag) const |
Brad King | c65a2ea | 2012-10-26 10:16:45 -0400 | [diff] [blame] | 248 | { |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 249 | // This method works only for single-valued flags! |
Ben Boeckel | c61ece5 | 2022-11-22 13:56:03 -0500 | [diff] [blame] | 250 | auto i = this->FlagMap.find(flag); |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 251 | if (i != this->FlagMap.cend() && i->second.size() == 1) { |
Brad King | 1c209ac | 2014-07-23 11:13:13 -0400 | [diff] [blame] | 252 | return i->second[0].c_str(); |
Kitware Robot | d9fd2f5 | 2016-05-16 10:34:04 -0400 | [diff] [blame] | 253 | } |
Vitaly Stakhovsky | c62ffdc | 2017-12-08 22:30:16 -0500 | [diff] [blame] | 254 | return nullptr; |
Brad King | c65a2ea | 2012-10-26 10:16:45 -0400 | [diff] [blame] | 255 | } |