diff options
-rw-r--r-- | Source/cmIncludeDirectoryCommand.cxx | 15 | ||||
-rw-r--r-- | Tests/IncludeDirectories/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/IncludeDirectories/empty.cpp | 1 |
3 files changed, 25 insertions, 2 deletions
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index ffb0e8086b..30c174375d 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 8a60f17d82..3e3ecc90dc 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 0000000000..ab32cf6c8a --- /dev/null +++ b/Tests/IncludeDirectories/empty.cpp @@ -0,0 +1 @@ +// No content |