summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-11-15 14:57:38 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-11-15 14:57:56 (GMT)
commit5695b0464b411746b207da2ee23b8e2d9f8ffec2 (patch)
tree82e1a00666f6e8a026b7af578801b9b38d8e04ce
parent1d78e1a966912d35e1dea0e986bc0b977141e880 (diff)
parent2d0100fac7a51327ce8053b4ab2277aaa96c12a5 (diff)
downloadCMake-5695b0464b411746b207da2ee23b8e2d9f8ffec2.zip
CMake-5695b0464b411746b207da2ee23b8e2d9f8ffec2.tar.gz
CMake-5695b0464b411746b207da2ee23b8e2d9f8ffec2.tar.bz2
Merge topic 'cmake-e-rm'
2d0100fac7 replace remove and remove_directory with rm in tests 5239fc5c75 cmake -E: Add rm with improved semantics over remove and remove_directory Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3949
-rw-r--r--Help/manual/cmake.1.rst24
-rw-r--r--Help/release/dev/command_rm.rst12
-rw-r--r--Modules/CMakeAddFortranSubdirectory.cmake2
-rw-r--r--Modules/ExternalProject.cmake6
-rw-r--r--Modules/FindCUDA.cmake2
-rw-r--r--Modules/FindCUDA/run_nvcc.cmake6
-rw-r--r--Modules/Platform/Generic-SDCC-C.cmake2
-rw-r--r--Modules/Platform/Windows-GNU.cmake2
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx2
-rw-r--r--Source/cmcmd.cxx92
-rw-r--r--Tests/CMakeTestMultipleConfigures/RunCMake.cmake6
-rw-r--r--Tests/CPackComponentsDEB/CMakeLists.txt2
-rw-r--r--Tests/Complex/CMakeLists.txt2
-rw-r--r--Tests/Complex/Library/CMakeLists.txt2
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt2
-rw-r--r--Tests/ComplexOneConfig/Library/CMakeLists.txt2
-rw-r--r--Tests/CustomCommand/CMakeLists.txt4
-rw-r--r--Tests/ExportImport/CMakeLists.txt2
-rw-r--r--Tests/FortranOnly/CMakeLists.txt4
-rw-r--r--Tests/JavaExportImport/CMakeLists.txt2
-rw-r--r--Tests/LinkDirectory/CMakeLists.txt2
-rw-r--r--Tests/MacRuntimePath/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake2
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake8
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake70
-rw-r--r--Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input2
-rw-r--r--Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input2
-rw-r--r--Tests/StagingPrefix/CMakeLists.txt2
-rw-r--r--Tests/SubDir/Examples/example1/CMakeLists.txt2
-rw-r--r--Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt2
-rw-r--r--Tests/VSMidl/CMakeLists.txt4
-rw-r--r--Utilities/CMakeLists.txt2
-rw-r--r--Utilities/cmcurl/CMake/cmake_uninstall.cmake.in2
-rw-r--r--cmake_uninstall.cmake.in2
70 files changed, 287 insertions, 54 deletions
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 71110d1..6f33866 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -554,22 +554,38 @@ Available commands are:
7a0b54896fe5e70cca6dd643ad6f672614b189bf26f8153061c4d219474b05dad08c4e729af9f4b009f1a1a280cb625454bf587c690f4617c27e3aebdf3b7a2d file2.txt
``remove [-f] <file>...``
- Remove the file(s). If any of the listed files already do not
- exist, the command returns a non-zero exit code, but no message
- is logged. The ``-f`` option changes the behavior to return a
+ .. deprecated:: 3.17
+
+ Remove the file(s). The planned behaviour was that if any of the
+ listed files already do not exist, the command returns a non-zero exit code,
+ but no message is logged. The ``-f`` option changes the behavior to return a
zero exit code (i.e. success) in such situations instead.
``remove`` does not follow symlinks. That means it remove only symlinks
and not files it point to.
+ The implementation was buggy and always returned 0. It cannot be fixed without
+ breaking backwards compatibility. Use ``rm`` instead.
+
``remove_directory <dir>...``
- Remove ``<dir>`` directories and their contents. If a directory does
+ .. deprecated:: 3.17
+
+ Remove ``<dir>`` directories and their contents. If a directory does
not exist it will be silently ignored. If ``<dir>`` is a symlink to
a directory, just the symlink will be removed.
+ Use ``rm`` instead.
``rename <oldname> <newname>``
Rename a file or directory (on one volume). If file with the ``<newname>`` name
already exists, then it will be silently replaced.
+``rm [-rRf] <file> <dir>...``
+ Remove the files ``<file>`` or directories ``dir``.
+ Use ``-r`` or ``-R`` to remove directories and their contents recursively.
+ If any of the listed files/directories do not exist, the command returns a
+ non-zero exit code, but no message is logged. The ``-f`` option changes
+ the behavior to return a zero exit code (i.e. success) in such
+ situations instead.
+
``server``
Launch :manual:`cmake-server(7)` mode.
diff --git a/Help/release/dev/command_rm.rst b/Help/release/dev/command_rm.rst
new file mode 100644
index 0000000..a58362e
--- /dev/null
+++ b/Help/release/dev/command_rm.rst
@@ -0,0 +1,12 @@
+Command-Line
+--------------------
+
+* :manual:`cmake(1)` gained a ``rm`` command line
+ option that can be used to remove directories (with ``-r`` or ``-R`` flag)
+ and files.
+ If the ``-f`` flag is not specified, attempting to remove a file that
+ doesn't exist returns an non-zero error code.
+ This command deprecates ``remove`` and ``remove_directory``.
+ The ``remove`` implementation was buggy and always returned 0 when ``force``
+ flag was not present and a file didn't exist. It cannot be fixed without
+ breaking backwards compatibility so we introduced ``rm``.
diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake
index 2613569..09e739d 100644
--- a/Modules/CMakeAddFortranSubdirectory.cmake
+++ b/Modules/CMakeAddFortranSubdirectory.cmake
@@ -155,7 +155,7 @@ function(cmake_add_fortran_subdirectory subdir)
# make the external project always run make with each build
externalproject_add_step(${project_name}_build forcebuild
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E rm -f
${CMAKE_CURRENT_BUILD_DIR}/${project_name}-prefix/src/${project_name}-stamp/${project_name}-build
DEPENDEES configure
DEPENDERS build
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index cd4e22d..1e54266 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1120,7 +1120,7 @@ if(NOT \"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
endif()
execute_process(
- COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
+ COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\"
RESULT_VARIABLE error_code
)
if(error_code)
@@ -1196,7 +1196,7 @@ if(NOT \"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\")
endif()
execute_process(
- COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
+ COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\"
RESULT_VARIABLE error_code
)
if(error_code)
@@ -2580,7 +2580,7 @@ function(_ep_add_download_command name)
if(IS_DIRECTORY "${url}")
get_filename_component(abs_dir "${url}" ABSOLUTE)
set(comment "Performing download step (DIR copy) for '${name}'")
- set(cmd ${CMAKE_COMMAND} -E remove_directory ${source_dir}
+ set(cmd ${CMAKE_COMMAND} -E rm -rf ${source_dir}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir})
else()
get_property(no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT SET)
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 2a3e131..ad7fe99 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -2006,7 +2006,7 @@ macro(CUDA_BUILD_CLEAN_TARGET)
string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name)
endif()
add_custom_target(${cuda_clean_target_name}
- COMMAND ${CMAKE_COMMAND} -E remove ${CUDA_ADDITIONAL_CLEAN_FILES})
+ COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES})
# Clear out the variable, so the next time we configure it will be empty.
# This is useful so that the files won't persist in the list after targets
diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake
index af15d55..ba35433 100644
--- a/Modules/FindCUDA/run_nvcc.cmake
+++ b/Modules/FindCUDA/run_nvcc.cmake
@@ -174,7 +174,7 @@ endmacro()
# Delete the target file
cuda_execute_process(
"Removing ${generated_file}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
+ COMMAND "${CMAKE_COMMAND}" -E rm -f "${generated_file}"
)
# For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag
@@ -241,7 +241,7 @@ endif()
# Delete the temporary file
cuda_execute_process(
"Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}"
+ COMMAND "${CMAKE_COMMAND}" -E rm -f "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}"
)
if(CUDA_result)
@@ -267,7 +267,7 @@ if(CUDA_result)
# Since nvcc can sometimes leave half done files make sure that we delete the output file.
cuda_execute_process(
"Removing ${generated_file}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
+ COMMAND "${CMAKE_COMMAND}" -E rm -f "${generated_file}"
)
message(FATAL_ERROR "Error generating file ${generated_file}")
else()
diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake
index aef4abf..8f648a1 100644
--- a/Modules/Platform/Generic-SDCC-C.cmake
+++ b/Modules/Platform/Generic-SDCC-C.cmake
@@ -47,7 +47,7 @@ set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> -o <TARGET> <C
# needs sdcc 2.7.0 + sddclib from cvs
set(CMAKE_C_CREATE_STATIC_LIBRARY
- "\"${CMAKE_COMMAND}\" -E remove <TARGET>"
+ "\"${CMAKE_COMMAND}\" -E rm -f <TARGET>"
"<CMAKE_AR> -a <TARGET> <LINK_FLAGS> <OBJECTS> ")
# not supported by sdcc
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index 71189b1..cf85367 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -124,7 +124,7 @@ macro(__windows_compiler_gnu lang)
string(REPLACE "<OBJECTS>" "-Wl,--whole-archive <OBJECT_DIR>/objects.a -Wl,--no-whole-archive"
CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}")
set(CMAKE_${lang}_${rule}
- "<CMAKE_COMMAND> -E remove -f <OBJECT_DIR>/objects.a"
+ "<CMAKE_COMMAND> -E rm -f <OBJECT_DIR>/objects.a"
"<CMAKE_AR> cr <OBJECT_DIR>/objects.a <OBJECTS>"
"${CMAKE_${lang}_${rule}}"
)
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index ce3be63..7b6d0f3 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -629,7 +629,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeVariables(
<< "# The command to remove a file.\n"
<< "RM = "
<< cmakeShellCommand
- << " -E remove -f\n"
+ << " -E rm -f\n"
<< "\n";
makefileStream
<< "# Escaping for special characters.\n"
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index beedef4..72bef21 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -486,7 +486,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
- linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE");
+ linkCmds.push_back(cmakeCommand + " -E rm -f $TARGET_FILE");
}
// TODO: Use ARCHIVE_APPEND for archives over a certain size.
{
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index d05e3c8..c2fbb43 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -107,10 +107,12 @@ void CMakeCommandUsage(const char* program)
<< " sha384sum <file>... - create SHA384 checksum of files\n"
<< " sha512sum <file>... - create SHA512 checksum of files\n"
<< " remove [-f] <file>... - remove the file(s), use -f to force "
- "it\n"
- << " remove_directory <dir>... - remove directories and their contents\n"
+ "it (deprecated: use rm instead)\n"
+ << " remove_directory <dir>... - remove directories and their contents (deprecated: use rm instead)\n"
<< " rename oldname newname - rename a file or directory "
"(on one volume)\n"
+ << " rm [-rRf] <file/dir>... - remove files or directories, use -f to "
+ "force it, r or R to remove directories and their contents recursively\n"
<< " server - start cmake in server mode\n"
<< " sleep <number>... - sleep for given number of seconds\n"
<< " tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
@@ -172,6 +174,24 @@ static bool cmTarFilesFrom(std::string const& file,
return true;
}
+static bool cmRemoveDirectory(const std::string& dir, bool recursive = true)
+{
+ if (cmSystemTools::FileIsSymlink(dir)) {
+ if (!cmSystemTools::RemoveFile(dir)) {
+ std::cerr << "Error removing directory symlink \"" << dir << "\".\n";
+ return false;
+ }
+ } else if (!recursive) {
+ std::cerr << "Error removing directory \"" << dir
+ << "\" without recursive option.\n";
+ return false;
+ } else if (!cmSystemTools::RemoveADirectory(dir)) {
+ std::cerr << "Error removing directory \"" << dir << "\".\n";
+ return false;
+ }
+ return true;
+}
+
static int HandleIWYU(const std::string& runCmd,
const std::string& /* sourceFile */,
const std::vector<std::string>& orig_cmd)
@@ -706,14 +726,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
bool return_value = false;
for (auto const& arg : cmMakeRange(args).advance(2)) {
if (cmSystemTools::FileIsDirectory(arg)) {
- if (cmSystemTools::FileIsSymlink(arg)) {
- if (!cmSystemTools::RemoveFile(arg)) {
- std::cerr << "Error removing directory symlink \"" << arg
- << "\".\n";
- return_value = true;
- }
- } else if (!cmSystemTools::RemoveADirectory(arg)) {
- std::cerr << "Error removing directory \"" << arg << "\".\n";
+ if (!cmRemoveDirectory(arg)) {
return_value = true;
}
}
@@ -739,6 +752,65 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return 0;
}
+ // Remove directories or files with rm
+ if (args[1] == "rm" && args.size() > 2) {
+ // If an error occurs, we want to continue removing the remaining
+ // files/directories.
+ int return_value = 0;
+ bool force = false;
+ bool recursive = false;
+ bool doing_options = true;
+ bool at_least_one_file = false;
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (doing_options && cmHasLiteralPrefix(arg, "-")) {
+ if (arg == "--") {
+ doing_options = false;
+ }
+ if (arg.find('f') != std::string::npos) {
+ force = true;
+ }
+ if (arg.find_first_of("rR") != std::string::npos) {
+ recursive = true;
+ }
+ if (arg.find_first_not_of("-frR") != std::string::npos) {
+ cmSystemTools::Error("Unknown -E rm argument: " + arg);
+ return 1;
+ }
+ } else {
+ if (arg.empty()) {
+ continue;
+ }
+ at_least_one_file = true;
+ // Complain if the -f option was not given and
+ // either file does not exist or
+ // file could not be removed and still exists
+ bool file_exists_or_forced_remove = cmSystemTools::FileExists(arg) ||
+ cmSystemTools::FileIsSymlink(arg) || force;
+ if (cmSystemTools::FileIsDirectory(arg)) {
+ if (!cmRemoveDirectory(arg, recursive)) {
+ return_value = 1;
+ }
+ } else if ((!file_exists_or_forced_remove) ||
+ (!cmSystemTools::RemoveFile(arg) &&
+ cmSystemTools::FileExists(arg))) {
+ if (!file_exists_or_forced_remove) {
+ cmSystemTools::Error(
+ "File to remove does not exist and force is not set: " + arg);
+ } else {
+ cmSystemTools::Error("File can't be removed and still exist: " +
+ arg);
+ }
+ return_value = 1;
+ }
+ }
+ }
+ if (!at_least_one_file) {
+ cmSystemTools::Error("Missing file/directory to remove");
+ return 1;
+ }
+ return return_value;
+ }
+
// Touch file
if (args[1] == "touch" && args.size() > 2) {
for (auto const& arg : cmMakeRange(args).advance(2)) {
diff --git a/Tests/CMakeTestMultipleConfigures/RunCMake.cmake b/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
index 9632664..a79bfcb 100644
--- a/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
+++ b/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
@@ -21,11 +21,11 @@ set(N 7)
# First setup source and binary trees:
#
-execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory
+execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf
${dir}/Source
)
-execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory
+execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf
${dir}/Build
)
@@ -69,7 +69,7 @@ foreach(i RANGE 1 ${N})
# Save this iteration of the Build directory:
#
- execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory
+ execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf
${dir}/b${i}
)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory
diff --git a/Tests/CPackComponentsDEB/CMakeLists.txt b/Tests/CPackComponentsDEB/CMakeLists.txt
index bc5b6a9..4363f1b 100644
--- a/Tests/CPackComponentsDEB/CMakeLists.txt
+++ b/Tests/CPackComponentsDEB/CMakeLists.txt
@@ -104,7 +104,7 @@ install(FILES ${CPackComponentsDEB_BINARY_DIR}/symtest
COMPONENT applications)
if(EXISTS "./dirtest")
- execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ./dirtest)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ./dirtest)
endif()
# NOTE: directory left empty on purpose
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ./dirtest)
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 2e41754..9fd85be 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -324,7 +324,7 @@ if (WIN32)
${file}
"[${hkey}]" DOC "Registry_Test_Path")
exec_program(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"")
- exec_program(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"")
+ exec_program(${CMAKE_COMMAND} ARGS "-E rm -f \"${dir}/${file}\"")
endif ()
endif ()
diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt
index 64f6dc8..df874ef 100644
--- a/Tests/Complex/Library/CMakeLists.txt
+++ b/Tests/Complex/Library/CMakeLists.txt
@@ -131,7 +131,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM)
# Custom target to try preprocessing invocation.
add_custom_target(test_preprocess ${MAYBE_ALL}
- COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i
+ COMMAND ${CMAKE_COMMAND} -E rm -f CMakeFiles/create_file.dir/create_file.i
COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index 628cd4e..28b73af 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -281,7 +281,7 @@ if (WIN32)
${file}
"[${hkey}]" DOC "Registry_Test_Path")
exec_program(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"")
- exec_program(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"")
+ exec_program(${CMAKE_COMMAND} ARGS "-E rm -f \"${dir}/${file}\"")
endif ()
endif ()
diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt
index 64f6dc8..df874ef 100644
--- a/Tests/ComplexOneConfig/Library/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt
@@ -131,7 +131,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM)
# Custom target to try preprocessing invocation.
add_custom_target(test_preprocess ${MAYBE_ALL}
- COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i
+ COMMAND ${CMAKE_COMMAND} -E rm -f CMakeFiles/create_file.dir/create_file.i
COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index e9a9f52..e4b50d0 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -70,7 +70,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h APPEND
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1temp.h
${PROJECT_BINARY_DIR}/doc1.h
COMMAND ${CMAKE_COMMAND} -E echo " Removing doc1temp.h."
- COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/doc1temp.h
+ COMMAND ${CMAKE_COMMAND} -E rm -f ${PROJECT_BINARY_DIR}/doc1temp.h
)
# Add custom command to generate foo.h.
@@ -412,7 +412,7 @@ add_custom_target(do_check_command_line ALL
add_dependencies(do_check_command_line check_command_line)
add_custom_target(pre_check_command_line
- COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
+ COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
)
add_dependencies(do_check_command_line pre_check_command_line)
diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt
index dc621eb..d88eb11 100644
--- a/Tests/ExportImport/CMakeLists.txt
+++ b/Tests/ExportImport/CMakeLists.txt
@@ -7,7 +7,7 @@ endif()
# Wipe out the install tree to make sure the exporter works.
add_custom_command(
OUTPUT ${ExportImport_BINARY_DIR}/CleanupProject
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${ExportImport_BINARY_DIR}/Root
+ COMMAND ${CMAKE_COMMAND} -E rm -rf ${ExportImport_BINARY_DIR}/Root
)
add_custom_target(CleanupTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/CleanupProject)
set_property(
diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt
index de887fa..d945375 100644
--- a/Tests/FortranOnly/CMakeLists.txt
+++ b/Tests/FortranOnly/CMakeLists.txt
@@ -103,11 +103,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM)
# Custom target to try preprocessing invocation.
add_custom_target(test_preprocess ${MAYBE_ALL}
- COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/preprocess.dir/preprocess.F.i
+ COMMAND ${CMAKE_COMMAND} -E rm -f CMakeFiles/preprocess.dir/preprocess.F.i
COMMAND ${CMAKE_MAKE_PROGRAM} preprocess.i
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake
# Remove bogus file some compilers leave behind.
- COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/preprocess.s
+ COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_SOURCE_DIR}/preprocess.s
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
diff --git a/Tests/JavaExportImport/CMakeLists.txt b/Tests/JavaExportImport/CMakeLists.txt
index c70704a..7a2d020 100644
--- a/Tests/JavaExportImport/CMakeLists.txt
+++ b/Tests/JavaExportImport/CMakeLists.txt
@@ -9,7 +9,7 @@ find_package(Java COMPONENTS Development)
# Wipe out the install tree to make sure the exporter works.
add_custom_command(
OUTPUT ${JavaExportImport_BINARY_DIR}/CleanupProject
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${JavaExportImport_BINARY_DIR}/Root
+ COMMAND ${CMAKE_COMMAND} -E rm -rf ${JavaExportImport_BINARY_DIR}/Root
)
add_custom_target(CleanupTarget ALL DEPENDS ${JavaExportImport_BINARY_DIR}/CleanupProject)
set_property(
diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt
index c60de84..c7a2700 100644
--- a/Tests/LinkDirectory/CMakeLists.txt
+++ b/Tests/LinkDirectory/CMakeLists.txt
@@ -33,7 +33,7 @@ ExternalProject_Add(ExternalTarget
# directly because it does not know the full paths to the libraries.
# (The purpose of this test is to check that link_directories works.)
ExternalProject_Add_Step(ExternalTarget cleanup
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${LinkDirectory_BINARY_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E rm -rf ${LinkDirectory_BINARY_DIR}/bin
DEPENDEES download
DEPENDERS configure
DEPENDS mylibA mylibB
diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt
index a3c6fd9..9f1bf1a 100644
--- a/Tests/MacRuntimePath/CMakeLists.txt
+++ b/Tests/MacRuntimePath/CMakeLists.txt
@@ -7,7 +7,7 @@ endif()
# Wipe out the install tree to make sure the exporter works.
add_custom_command(
OUTPUT ${MacRuntimePath_BINARY_DIR}/CleanupProject
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${MacRuntimePath_BINARY_DIR}/Root
+ COMMAND ${CMAKE_COMMAND} -E rm -rf ${MacRuntimePath_BINARY_DIR}/Root
)
add_custom_target(CleanupTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/CleanupProject)
set_property(
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1371295..e88b29d 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -445,7 +445,7 @@ add_RunCMake_test(target_include_directories)
add_RunCMake_test(target_sources)
add_RunCMake_test(CheckModules)
add_RunCMake_test(CheckIPOSupported)
-add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
+add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCYGWIN=${CYGWIN})
add_RunCMake_test(CommandLineTar)
if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG))
diff --git a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake
index 7d63299..ef79dce 100644
--- a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake
+++ b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake
@@ -1,6 +1,6 @@
function(setup_resource_tests)
if(CTEST_RESOURCE_ALLOC_ENABLED)
- add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E remove -f "${CMAKE_BINARY_DIR}/ctresalloc.log")
+ add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E rm -f "${CMAKE_BINARY_DIR}/ctresalloc.log")
endif()
endfunction()
diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt
new file mode 100644
index 0000000..62b963a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Unknown -E rm argument: -rd$
diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake
new file mode 100644
index 0000000..b1a29a2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/dir/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt
new file mode 100644
index 0000000..1ac7dba
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Missing file/directory to remove$
diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake
new file mode 100644
index 0000000..6cd4edd
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake
@@ -0,0 +1,8 @@
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E rm ""
+ RESULT_VARIABLE actual_result
+ )
+
+if(NOT "${actual_result}" EQUAL "1")
+ message(SEND_ERROR "cmake -E rm \"\" should have returned 1, got ${actual_result}")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake
new file mode 100644
index 0000000..e28b160
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake
new file mode 100644
index 0000000..a0a9b20
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake
new file mode 100644
index 0000000..e28b160
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt
new file mode 100644
index 0000000..05df88a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake
new file mode 100644
index 0000000..e28b160
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt
new file mode 100644
index 0000000..05df88a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt
diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake
new file mode 100644
index 0000000..1a976cb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out})
+ set(RunCMake_TEST_FAILED "${out} not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt
new file mode 100644
index 0000000..1ac7dba
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Missing file/directory to remove$
diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake
new file mode 100644
index 0000000..609271e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/d1 OR NOT EXISTS ${out}/d2)
+ set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 is removed but should not")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt
new file mode 100644
index 0000000..33ea2e3
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt
@@ -0,0 +1,2 @@
+^Error removing directory ".*/rm_tests/d1" without recursive option\.
+Error removing directory ".*/rm_tests/d2" without recursive option\.$
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake
new file mode 100644
index 0000000..5282da7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/d1 OR EXISTS ${out}/d2)
+ set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 should be removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake
new file mode 100644
index 0000000..b1a29a2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/dir/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake
new file mode 100644
index 0000000..a0a9b20
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index f903c3d..bd368cb 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -388,6 +388,76 @@ endif()
unset(out)
unset(outfile)
+set(out ${RunCMake_BINARY_DIR}/rm_tests)
+file(REMOVE_RECURSE "${out}")
+file(MAKE_DIRECTORY ${out})
+file(TOUCH ${out}/existing.txt)
+run_cmake_command(E_rm_file_force_existing
+ ${CMAKE_COMMAND} -E rm -f ${out}/existing.txt)
+file(TOUCH ${out}/existing.txt)
+run_cmake_command(E_rm_file_non_force_existing
+ ${CMAKE_COMMAND} -E rm ${out}/existing.txt)
+run_cmake_command(E_rm_file_force_non_existing
+ ${CMAKE_COMMAND} -E rm -f ${out}/not_existing.txt)
+run_cmake_command(E_rm_file_non_force_non_existing
+ ${CMAKE_COMMAND} -E rm ${out}/not_existing.txt)
+
+file(TOUCH ${out}/existing.txt)
+run_cmake_command(E_rm_file_recursive_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/existing.txt)
+run_cmake_command(E_rm_file_recursive_non_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/not_existing.txt)
+
+file(MAKE_DIRECTORY ${out}/d1 ${out}/d2)
+run_cmake_command(E_rm_non_recursive_directory-two-directories
+ ${CMAKE_COMMAND} -E rm ${out}/d1 ${out}/d2)
+
+run_cmake_command(E_rm_recursive_directory-two-directories
+ ${CMAKE_COMMAND} -E rm -R ${out}/d1 ${out}/d2)
+
+run_cmake_command(E_rm_no_file_specified
+ ${CMAKE_COMMAND} -E rm -rf)
+
+run_cmake_command(E_rm_empty_file_specified
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_rm_empty_file_specified.cmake)
+
+run_cmake_command(E_rm_bad_argument
+ ${CMAKE_COMMAND} -E rm -rd ${out}/d1 ${out}/d2)
+
+file(MAKE_DIRECTORY ${out}/d1 ${out}/d2)
+file(WRITE ${out}/test.txt "")
+run_cmake_command(E_rm_force_recursive_directory_with_files
+ ${CMAKE_COMMAND} -E rm -rf ${out}/)
+
+run_cmake_command(E_rm_force_recursive_non_existing_file
+ ${CMAKE_COMMAND} -E rm -Rf ${out}/test.txt)
+
+if(NOT WIN32 AND NOT CYGWIN)
+ file(MAKE_DIRECTORY ${out})
+ file(TOUCH ${out}/existing.txt)
+ file(MAKE_DIRECTORY ${out}/dir)
+ file(TOUCH ${out}/dir/existing.txt) # add a file in the folder
+ file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC)
+ file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC)
+ file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC)
+ run_cmake_command(E_rm_file_link_existing
+ ${CMAKE_COMMAND} -E rm ${out}/existing_file_link.txt)
+ run_cmake_command(E_rm_directory_link_existing
+ ${CMAKE_COMMAND} -E rm ${out}/link_dir)
+ run_cmake_command(E_rm_file_link_non_existing
+ ${CMAKE_COMMAND} -E rm ${out}/non_existing_file_link.txt)
+
+ file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC)
+ file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC)
+ file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC)
+ run_cmake_command(E_rm_recursive_file_link_existing
+ ${CMAKE_COMMAND} -E rm -R ${out}/existing_file_link.txt)
+ run_cmake_command(E_rm_recursive_directory_link_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/link_dir)
+ run_cmake_command(E_rm_recursive_file_link_non_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/non_existing_file_link.txt)
+endif()
+unset(out)
run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env)
run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1)
diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input
index 81e9ee0..b1c4ce0 100644
--- a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input
+++ b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input
@@ -53,7 +53,7 @@ LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586'
Linking C executable cmTC_ab097.exe
"C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_ab097.dir\link.txt --verbose=1
-"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_ab097.dir/objects.a
+"C:\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_ab097.dir/objects.a
C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_ab097.dir/objects.a @CMakeFiles\cmTC_ab097.dir\objects1.rsp
C:\DoesNotExist\MinGW\bin\gcc.exe -v -Wl,--whole-archive CMakeFiles\cmTC_ab097.dir/objects.a -Wl,--no-whole-archive -o cmTC_ab097.exe -Wl,--out-implib,libcmTC_ab097.dll.a -Wl,--major-image-version,0,--minor-image-version,0
Using built-in specs.
diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input
index cd77340..aae67bb 100644
--- a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input
+++ b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input
@@ -59,7 +59,7 @@ LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586'
Linking CXX executable cmTC_2b790.exe
"C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_2b790.dir\link.txt --verbose=1
-"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_2b790.dir/objects.a
+"C:\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_2b790.dir/objects.a
C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_2b790.dir/objects.a @CMakeFiles\cmTC_2b790.dir\objects1.rsp
C:\DoesNotExist\MinGW\bin\g++.exe -v -Wl,--whole-archive CMakeFiles\cmTC_2b790.dir/objects.a -Wl,--no-whole-archive -o cmTC_2b790.exe -Wl,--out-implib,libcmTC_2b790.dll.a -Wl,--major-image-version,0,--minor-image-version,0
Using built-in specs.
diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt
index 8d2519e..9ed5c12 100644
--- a/Tests/StagingPrefix/CMakeLists.txt
+++ b/Tests/StagingPrefix/CMakeLists.txt
@@ -5,7 +5,7 @@ project(StagingPrefix)
# Wipe out the install tree
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject
- COMMAND ${CMAKE_COMMAND} -E remove_directory
+ COMMAND ${CMAKE_COMMAND} -E rm -rf
${CMAKE_BINARY_DIR}/ConsumerBuild
${CMAKE_BINARY_DIR}/ProducerBuild
${CMAKE_BINARY_DIR}/stage
diff --git a/Tests/SubDir/Examples/example1/CMakeLists.txt b/Tests/SubDir/Examples/example1/CMakeLists.txt
index 20d065e..8ec1c02 100644
--- a/Tests/SubDir/Examples/example1/CMakeLists.txt
+++ b/Tests/SubDir/Examples/example1/CMakeLists.txt
@@ -3,5 +3,5 @@ project(example1)
add_executable(example1 example1.cxx)
add_custom_command(TARGET example1 POST_BUILD
- COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere
+ COMMAND "${CMAKE_COMMAND}" ARGS -E rm -f ${SUBDIR_BINARY_DIR}/ShouldBeHere
COMMENT "Remove marker file that should exist because this should not be run")
diff --git a/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt b/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt
index 20d065e..8ec1c02 100644
--- a/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt
+++ b/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt
@@ -3,5 +3,5 @@ project(example1)
add_executable(example1 example1.cxx)
add_custom_command(TARGET example1 POST_BUILD
- COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere
+ COMMAND "${CMAKE_COMMAND}" ARGS -E rm -f ${SUBDIR_BINARY_DIR}/ShouldBeHere
COMMENT "Remove marker file that should exist because this should not be run")
diff --git a/Tests/VSMidl/CMakeLists.txt b/Tests/VSMidl/CMakeLists.txt
index 432506c..3ff7c27 100644
--- a/Tests/VSMidl/CMakeLists.txt
+++ b/Tests/VSMidl/CMakeLists.txt
@@ -56,8 +56,8 @@ set(source_dir "${base_dir}/src")
#
ExternalProject_Add(clean-${PROJECT_NAME}
DOWNLOAD_COMMAND ""
- CONFIGURE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${source_dir}"
- BUILD_COMMAND ${CMAKE_COMMAND} -E remove_directory "${binary_dir}"
+ CONFIGURE_COMMAND ${CMAKE_COMMAND} -E rm -rf "${source_dir}"
+ BUILD_COMMAND ${CMAKE_COMMAND} -E rm -rf "${binary_dir}"
INSTALL_COMMAND ""
)
diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt
index 0564540..22a3d5a 100644
--- a/Utilities/CMakeLists.txt
+++ b/Utilities/CMakeLists.txt
@@ -13,7 +13,7 @@ if(CMAKE_DOC_TARBALL)
endif()
add_custom_command(
OUTPUT ${dir}.stamp
- COMMAND cmake -E remove_directory ${dir}
+ COMMAND cmake -E rm -rf ${dir}
COMMAND cmake -E tar xf ${CMAKE_DOC_TARBALL}
COMMAND cmake -E touch ${dir}.stamp
DEPENDS ${CMAKE_DOC_TARBALL}
diff --git a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
index db8e536..5178fd8 100644
--- a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
+++ b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
@@ -13,7 +13,7 @@ foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
- "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ "@CMAKE_COMMAND@" ARGS "-E rm -f \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
index d81f62a..b5fc700 100644
--- a/cmake_uninstall.cmake.in
+++ b/cmake_uninstall.cmake.in
@@ -8,7 +8,7 @@ foreach(file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if(EXISTS "$ENV{DESTDIR}${file}")
exec_program(
- "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ "@CMAKE_COMMAND@" ARGS "-E rm -f \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)