summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-05-20 10:25:59 (GMT)
committerBrad King <brad.king@kitware.com>2013-05-24 20:40:58 (GMT)
commitb8cc6f4eba0b7349de81a48aea18a43f99e78ca5 (patch)
tree8dcf848166fb4f2846d02a5e9d62b83da3a4b912
parent5dd8c01429da90a7417b72f17e784cc98f70f57c (diff)
downloadCMake-b8cc6f4eba0b7349de81a48aea18a43f99e78ca5.zip
CMake-b8cc6f4eba0b7349de81a48aea18a43f99e78ca5.tar.gz
CMake-b8cc6f4eba0b7349de81a48aea18a43f99e78ca5.tar.bz2
include_directories: Fix handling of empty or space-only entries
Since commit 0d46e9a0 (Store includes from the same include_directories call together., 2013-01-20) we accidentally use such entries. Fix the code to drop them instead. Update the IncludeDirectories test to cover this case. Reported-by: Christophe Giboudeaux <cgiboudeaux@gmx.com>
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx15
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt11
-rw-r--r--Tests/IncludeDirectories/empty.cpp4
3 files changed, 28 insertions, 2 deletions
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index ffb0e80..30c1743 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -116,13 +116,19 @@ void cmIncludeDirectoryCommand::GetIncludes(const std::string &arg,
{
std::string inc = arg.substr(lastPos,pos);
this->NormalizeInclude(inc);
- incs.push_back(inc);
+ if (!inc.empty())
+ {
+ incs.push_back(inc);
+ }
}
lastPos = pos + 1;
}
std::string inc = arg.substr(lastPos);
this->NormalizeInclude(inc);
- incs.push_back(inc);
+ if (!inc.empty())
+ {
+ incs.push_back(inc);
+ }
}
void cmIncludeDirectoryCommand::NormalizeInclude(std::string &inc)
@@ -133,6 +139,11 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string &inc)
{
inc.assign(inc, b, 1+e-b); // copy the remaining substring
}
+ else
+ {
+ inc = "";
+ return;
+ }
if (!cmSystemTools::IsOff(inc.c_str()))
{
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index 8a60f17..3e3ecc9 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -58,3 +58,14 @@ get_property(propContentAfter DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
if (NOT propContentAfter STREQUAL "")
message(SEND_ERROR "Clearing DIRECTORY property failed.")
endif()
+
+add_library(empty_entry_test SHARED empty.cpp)
+set_target_properties(empty_entry_test PROPERTIES INCLUDE_DIRECTORIES "")
+include_directories(/one/two
+ " "
+ " "
+)
+get_target_property(incs empty_entry_test INCLUDE_DIRECTORIES)
+if (NOT incs STREQUAL ";/one/two")
+ message(SEND_ERROR "Empty include_directories entry was not ignored.")
+endif()
diff --git a/Tests/IncludeDirectories/empty.cpp b/Tests/IncludeDirectories/empty.cpp
new file mode 100644
index 0000000..1787013
--- /dev/null
+++ b/Tests/IncludeDirectories/empty.cpp
@@ -0,0 +1,4 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty() { return 0; }