summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmMakefile.cxx26
-rw-r--r--Tests/Complex/Executable/CMakeLists.txt8
-rw-r--r--Tests/Complex/Executable/complex.cxx12
-rw-r--r--Tests/ComplexOneConfig/Executable/CMakeLists.txt8
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx12
-rw-r--r--Tests/ComplexRelativePaths/Executable/CMakeLists.txt8
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx12
7 files changed, 85 insertions, 1 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index da86aea..fc92d45 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -36,6 +36,8 @@
#include <cmsys/RegularExpression.hxx>
+#include <ctype.h> // for isspace
+
// default is not to be building executables
cmMakefile::cmMakefile()
{
@@ -803,7 +805,29 @@ void cmMakefile::AddDefineFlag(const char* flag)
void cmMakefile::RemoveDefineFlag(const char* flag)
{
- cmSystemTools::ReplaceString(this->DefineFlags, flag, " ");
+ // Check the length of the flag to remove.
+ std::string::size_type len = strlen(flag);
+ if(len < 1)
+ {
+ return;
+ }
+
+ // Remove all instances of the flag that are surrounded by
+ // whitespace or the beginning/end of the string.
+ for(std::string::size_type lpos = this->DefineFlags.find(flag, 0);
+ lpos != std::string::npos; lpos = this->DefineFlags.find(flag, lpos))
+ {
+ std::string::size_type rpos = lpos + len;
+ if((lpos <= 0 || isspace(this->DefineFlags[lpos-1])) &&
+ (rpos >= this->DefineFlags.size() || isspace(this->DefineFlags[rpos])))
+ {
+ this->DefineFlags.erase(lpos, len);
+ }
+ else
+ {
+ ++lpos;
+ }
+ }
}
void cmMakefile::AddLinkLibrary(const char* lib,
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
index 6a217f0..dae5775 100644
--- a/Tests/Complex/Executable/CMakeLists.txt
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -55,6 +55,14 @@ IF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_C
ADD_DEFINITIONS(-DCMAKE_FOUND_LISTFILE_STACK)
ENDIF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake")
+# Test add/remove definitions.
+ADD_DEFINITIONS(
+ -DCOMPLEX_DEFINED_PRE
+ -DCOMPLEX_DEFINED
+ -DCOMPLEX_DEFINED_POST
+ -DCOMPLEX_DEFINED
+ )
+REMOVE_DEFINITIONS(-DCOMPLEX_DEFINED)
# Test pre-build/pre-link/post-build rules for an executable.
ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index a80487b..816414c 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -42,6 +42,18 @@ void cmPassed(const char* Message, const char* m2="")
cm_passed++;
}
+#ifndef COMPLEX_DEFINED_PRE
+# error "COMPLEX_DEFINED_PRE not defined!"
+#endif
+
+#ifdef COMPLEX_DEFINED
+# error "COMPLEX_DEFINED is defined but it should not!"
+#endif
+
+#ifndef COMPLEX_DEFINED_POST
+# error "COMPLEX_DEFINED_POST not defined!"
+#endif
+
#ifndef CMAKE_IS_REALLY_FUN
This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif
diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
index 6a217f0..dae5775 100644
--- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
@@ -55,6 +55,14 @@ IF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_C
ADD_DEFINITIONS(-DCMAKE_FOUND_LISTFILE_STACK)
ENDIF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake")
+# Test add/remove definitions.
+ADD_DEFINITIONS(
+ -DCOMPLEX_DEFINED_PRE
+ -DCOMPLEX_DEFINED
+ -DCOMPLEX_DEFINED_POST
+ -DCOMPLEX_DEFINED
+ )
+REMOVE_DEFINITIONS(-DCOMPLEX_DEFINED)
# Test pre-build/pre-link/post-build rules for an executable.
ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index a80487b..816414c 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -42,6 +42,18 @@ void cmPassed(const char* Message, const char* m2="")
cm_passed++;
}
+#ifndef COMPLEX_DEFINED_PRE
+# error "COMPLEX_DEFINED_PRE not defined!"
+#endif
+
+#ifdef COMPLEX_DEFINED
+# error "COMPLEX_DEFINED is defined but it should not!"
+#endif
+
+#ifndef COMPLEX_DEFINED_POST
+# error "COMPLEX_DEFINED_POST not defined!"
+#endif
+
#ifndef CMAKE_IS_REALLY_FUN
This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif
diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
index 6a217f0..dae5775 100644
--- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
@@ -55,6 +55,14 @@ IF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_C
ADD_DEFINITIONS(-DCMAKE_FOUND_LISTFILE_STACK)
ENDIF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake")
+# Test add/remove definitions.
+ADD_DEFINITIONS(
+ -DCOMPLEX_DEFINED_PRE
+ -DCOMPLEX_DEFINED
+ -DCOMPLEX_DEFINED_POST
+ -DCOMPLEX_DEFINED
+ )
+REMOVE_DEFINITIONS(-DCOMPLEX_DEFINED)
# Test pre-build/pre-link/post-build rules for an executable.
ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index a80487b..816414c 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -42,6 +42,18 @@ void cmPassed(const char* Message, const char* m2="")
cm_passed++;
}
+#ifndef COMPLEX_DEFINED_PRE
+# error "COMPLEX_DEFINED_PRE not defined!"
+#endif
+
+#ifdef COMPLEX_DEFINED
+# error "COMPLEX_DEFINED is defined but it should not!"
+#endif
+
+#ifndef COMPLEX_DEFINED_POST
+# error "COMPLEX_DEFINED_POST not defined!"
+#endif
+
#ifndef CMAKE_IS_REALLY_FUN
This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif