From 4959f3413c83f38dd222dced11d7a3933e145ae4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Mar 2014 22:56:36 +0100 Subject: [PATCH] cmSourceFileLocation: Collapse full path for directory comparisons. Otherwise Matches() ends up doing a comparison of the directories /path/to/dir/subdir/.. and /path/to/dir as strings and not matching where it should. --- Source/cmSourceFileLocation.cxx | 5 +++++ Tests/Properties/CMakeLists.txt | 2 ++ Tests/Properties/SubDir2/CMakeLists.txt | 5 +++++ Tests/Properties/subdirtest.cxx | 9 +++++++++ 4 files changed, 21 insertions(+) create mode 100644 Tests/Properties/SubDir2/CMakeLists.txt create mode 100644 Tests/Properties/subdirtest.cxx diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 24e646fc9..c05020236 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -60,6 +60,11 @@ cmSourceFileLocation this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str()); this->AmbiguousExtension = true; this->Directory = cmSystemTools::GetFilenamePath(name); + if (cmSystemTools::FileIsFullPath(this->Directory.c_str())) + { + this->Directory + = cmSystemTools::CollapseFullPath(this->Directory.c_str()); + } this->Name = cmSystemTools::GetFilenameName(name); this->UpdateExtension(name); } diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index 285d5965e..11fca45b0 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -143,3 +143,5 @@ set_property(CACHE SOME_ENTRY PROPERTY VALUE "${expect_VALUE}") set_property(CACHE SOME_ENTRY PROPERTY ADVANCED "${expect_ADVANCED}") set_property(CACHE SOME_ENTRY PROPERTY STRINGS "${expect_STRINGS}") check_cache_props() + +add_subdirectory(SubDir2) diff --git a/Tests/Properties/SubDir2/CMakeLists.txt b/Tests/Properties/SubDir2/CMakeLists.txt new file mode 100644 index 000000000..377dc830e --- /dev/null +++ b/Tests/Properties/SubDir2/CMakeLists.txt @@ -0,0 +1,5 @@ + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx" + PROPERTIES COMPILE_DEFINITIONS SUBDIR_TEST) + +add_executable(subdirtest "${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx") diff --git a/Tests/Properties/subdirtest.cxx b/Tests/Properties/subdirtest.cxx new file mode 100644 index 000000000..02d8f3d3f --- /dev/null +++ b/Tests/Properties/subdirtest.cxx @@ -0,0 +1,9 @@ + +#ifndef SUBDIR_TEST +#error Expected SUBDIR_TEST +#endif + +int main(int, char**) +{ + return 0; +}