summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2018-04-30 14:50:23 (GMT)
committerBrad King <brad.king@kitware.com>2018-05-01 14:25:49 (GMT)
commit0c47ed643046428617161959a5784d3d70cf5a1f (patch)
tree44f8cc2dc6c233d2706ee125b27f11ddd8a15d23
parente13fa223fc870ea95c6a1cfa09b61b527a1c2db5 (diff)
downloadCMake-0c47ed643046428617161959a5784d3d70cf5a1f.zip
CMake-0c47ed643046428617161959a5784d3d70cf5a1f.tar.gz
CMake-0c47ed643046428617161959a5784d3d70cf5a1f.tar.bz2
cmMakefile: Convert private helpers to file static functions
The two-argument forms of `AddDefineFlag` and `RemoveDefineFlag` need no access to `cmMakefile` class members. They are used only within the implementation file.
-rw-r--r--Source/cmMakefile.cxx60
-rw-r--r--Source/cmMakefile.h3
2 files changed, 30 insertions, 33 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 53f0a3d..33e76b2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1130,57 +1130,38 @@ cmTarget* cmMakefile::AddUtilityCommand(
return target;
}
-void cmMakefile::AddDefineFlag(std::string const& flag)
-{
- if (flag.empty()) {
- return;
- }
-
- // Update the string used for the old DEFINITIONS property.
- this->AddDefineFlag(flag, this->DefineFlagsOrig);
-
- // If this is really a definition, update COMPILE_DEFINITIONS.
- if (this->ParseDefineFlag(flag, false)) {
- return;
- }
-
- // Add this flag that does not look like a definition.
- this->AddDefineFlag(flag, this->DefineFlags);
-}
-
-void cmMakefile::AddDefineFlag(std::string const& flag, std::string& dflags)
+static void s_AddDefineFlag(std::string const& flag, std::string& dflags)
{
// remove any \n\r
std::string::size_type initSize = dflags.size();
- dflags += std::string(" ") + flag;
+ dflags += ' ';
+ dflags += flag;
std::string::iterator flagStart = dflags.begin() + initSize + 1;
std::replace(flagStart, dflags.end(), '\n', ' ');
std::replace(flagStart, dflags.end(), '\r', ' ');
}
-void cmMakefile::RemoveDefineFlag(std::string const& flag)
+void cmMakefile::AddDefineFlag(std::string const& flag)
{
- // Check the length of the flag to remove.
if (flag.empty()) {
return;
}
- std::string::size_type const len = flag.length();
+
// Update the string used for the old DEFINITIONS property.
- this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
+ s_AddDefineFlag(flag, this->DefineFlagsOrig);
// If this is really a definition, update COMPILE_DEFINITIONS.
- if (this->ParseDefineFlag(flag, true)) {
+ if (this->ParseDefineFlag(flag, false)) {
return;
}
- // Remove this flag that does not look like a definition.
- this->RemoveDefineFlag(flag, len, this->DefineFlags);
+ // Add this flag that does not look like a definition.
+ s_AddDefineFlag(flag, this->DefineFlags);
}
-void cmMakefile::RemoveDefineFlag(std::string const& flag,
- std::string::size_type len,
- std::string& dflags)
+static void s_RemoveDefineFlag(std::string const& flag, std::string& dflags)
{
+ std::string::size_type const len = flag.length();
// Remove all instances of the flag that are surrounded by
// whitespace or the beginning/end of the string.
for (std::string::size_type lpos = dflags.find(flag, 0);
@@ -1195,6 +1176,25 @@ void cmMakefile::RemoveDefineFlag(std::string const& flag,
}
}
+void cmMakefile::RemoveDefineFlag(std::string const& flag)
+{
+ // Check the length of the flag to remove.
+ if (flag.empty()) {
+ return;
+ }
+
+ // Update the string used for the old DEFINITIONS property.
+ s_RemoveDefineFlag(flag, this->DefineFlagsOrig);
+
+ // If this is really a definition, update COMPILE_DEFINITIONS.
+ if (this->ParseDefineFlag(flag, true)) {
+ return;
+ }
+
+ // Remove this flag that does not look like a definition.
+ s_RemoveDefineFlag(flag, this->DefineFlags);
+}
+
void cmMakefile::AddCompileDefinition(std::string const& option)
{
this->AppendProperty("COMPILE_DEFINITIONS", option.c_str());
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 7a688b3..9f32c4f 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -885,9 +885,6 @@ protected:
std::string DefineFlags;
// Track the value of the computed DEFINITIONS property.
- void AddDefineFlag(std::string const& flag, std::string&);
- void RemoveDefineFlag(std::string const& flag, std::string::size_type,
- std::string&);
std::string DefineFlagsOrig;
#if defined(CMAKE_BUILD_WITH_CMAKE)