diff options
-rw-r--r-- | Source/cmFileCommand.cxx | 6 | ||||
-rw-r--r-- | Tests/RunCMake/file/MAKE_DIRECTORY-fail-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt | 9 | ||||
-rw-r--r-- | Tests/RunCMake/file/MAKE_DIRECTORY-fail.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/file/RunCMakeTest.cmake | 2 |
5 files changed, 18 insertions, 2 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index cdd0408..dfce033 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -845,8 +845,10 @@ bool HandleMakeDirectoryCommand(std::vector<std::string> const& args, cmSystemTools::SetFatalErrorOccurred(); return false; } - if (!cmSystemTools::MakeDirectory(*cdir)) { - std::string error = "problem creating directory: " + *cdir; + cmsys::Status mkdirStatus = cmSystemTools::MakeDirectory(*cdir); + if (!mkdirStatus) { + std::string error = cmStrCat("failed to create directory:\n ", *cdir, + "\nbecause: ", mkdirStatus.GetString()); status.SetError(error); return false; } diff --git a/Tests/RunCMake/file/MAKE_DIRECTORY-fail-result.txt b/Tests/RunCMake/file/MAKE_DIRECTORY-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/MAKE_DIRECTORY-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt b/Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt new file mode 100644 index 0000000..95fccdf --- /dev/null +++ b/Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at [^ +]*/MAKE_DIRECTORY-fail.cmake:[0-9]+ \(file\): + file failed to create directory: + + [^ +]*/Tests/RunCMake/file/MAKE_DIRECTORY-fail-build/file/directory + + because: [^ +]+$ diff --git a/Tests/RunCMake/file/MAKE_DIRECTORY-fail.cmake b/Tests/RunCMake/file/MAKE_DIRECTORY-fail.cmake new file mode 100644 index 0000000..57a68e5 --- /dev/null +++ b/Tests/RunCMake/file/MAKE_DIRECTORY-fail.cmake @@ -0,0 +1,2 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/file" "") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/file/directory") diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 752f7a0..c75e062 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -61,6 +61,8 @@ run_cmake_script(COPY_FILE-arg-unknown) run_cmake_script(COPY_FILE-input-missing) run_cmake_script(COPY_FILE-output-missing) +run_cmake_script(MAKE_DIRECTORY-fail) + run_cmake_script(RENAME-file-replace) run_cmake_script(RENAME-file-to-file) run_cmake_script(RENAME-file-to-dir-capture) |