diff options
author | Brad King <brad.king@kitware.com> | 2019-11-04 15:27:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-11-04 15:27:18 (GMT) |
commit | bd1f350883fe0c276b319873d38164b56689b8bb (patch) | |
tree | 060309be04ad5b12f60d46c9917ada5fd7a09210 | |
parent | 9decc17a232055ccd8510e9c92383d0f3299f424 (diff) | |
parent | 0692eaf0fe00fd4bd90c2a4f107356b2bc0f9d99 (diff) | |
download | CMake-bd1f350883fe0c276b319873d38164b56689b8bb.zip CMake-bd1f350883fe0c276b319873d38164b56689b8bb.tar.gz CMake-bd1f350883fe0c276b319873d38164b56689b8bb.tar.bz2 |
Merge branch 'root-dir-assertion-fix' into release-3.16
Merge-request: !3976
-rw-r--r-- | Source/cmSystemTools.cxx | 9 | ||||
-rw-r--r-- | Tests/RunCMake/message/RunCMakeTest.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/message/warnmessage-rootdir-stderr.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/message/warnmessage-rootdir.cmake | 5 |
4 files changed, 22 insertions, 2 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a50e829..c4a4220 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1120,8 +1120,13 @@ std::string cmSystemTools::ForceToRelativePath(std::string const& local_path, assert(local_path.front() != '\"'); assert(remote_path.front() != '\"'); - // The local path should never have a trailing slash. - assert(local_path.empty() || local_path.back() != '/'); + // The local path should never have a trailing slash except if it is just the + // bare root directory + assert(local_path.empty() || local_path.back() != '/' || + local_path.size() == 1 || + (local_path.size() == 3 && local_path[1] == ':' && + ((local_path[0] >= 'A' && local_path[0] <= 'Z') || + (local_path[0] >= 'a' && local_path[0] <= 'z')))); // If the path is already relative then just return the path. if (!cmSystemTools::FileIsFullPath(remote_path)) { diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake index 9198a25..681839d 100644 --- a/Tests/RunCMake/message/RunCMakeTest.cmake +++ b/Tests/RunCMake/message/RunCMakeTest.cmake @@ -5,6 +5,15 @@ run_cmake(nomessage) run_cmake(message-internal-warning) run_cmake(nomessage-internal-warning) run_cmake(warnmessage) + +# Have to explicitly give the command for the working dir to be honoured +set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY /) +run_cmake_command( + warnmessage-rootdir + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/warnmessage-rootdir.cmake + ) +unset(RunCMake_TEST_COMMAND_WORKING_DIRECTORY) + # message command sets fatal occurred flag, so check each type of error # separately diff --git a/Tests/RunCMake/message/warnmessage-rootdir-stderr.txt b/Tests/RunCMake/message/warnmessage-rootdir-stderr.txt new file mode 100644 index 0000000..19d9398 --- /dev/null +++ b/Tests/RunCMake/message/warnmessage-rootdir-stderr.txt @@ -0,0 +1 @@ +We expect to see this warning message diff --git a/Tests/RunCMake/message/warnmessage-rootdir.cmake b/Tests/RunCMake/message/warnmessage-rootdir.cmake new file mode 100644 index 0000000..f82efb9 --- /dev/null +++ b/Tests/RunCMake/message/warnmessage-rootdir.cmake @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.15) + +# Generating the backtrace for this warning message used to trigger a +# spurious assertion when the current directory is the root directory +message(WARNING "We expect to see this warning message") |