cmake: Teach -E copy_directory to support multiple input directories
This commit is contained in:
parent
98be140fc0
commit
bc35087da3
|
@ -174,8 +174,9 @@ Available commands are:
|
||||||
If multiple files are specified, the ``<destination>`` must be
|
If multiple files are specified, the ``<destination>`` must be
|
||||||
directory and it must exist.
|
directory and it must exist.
|
||||||
|
|
||||||
``copy_directory <source> <destination>``
|
``copy_directory <dir>... <destination>``
|
||||||
Copy directory 'source' content to directory 'destination'.
|
Copy directories to ``<destination>`` directory.
|
||||||
|
If ``<destination>`` directory does not exist it will be created.
|
||||||
|
|
||||||
``copy_if_different <file>... <destination>``
|
``copy_if_different <file>... <destination>``
|
||||||
Copy files to ``<destination>`` (either file or directory) if
|
Copy files to ``<destination>`` (either file or directory) if
|
||||||
|
|
|
@ -3,3 +3,6 @@ cmake-E-copy-multiple-inputs
|
||||||
|
|
||||||
* The :manual:`cmake(1)` ``-E copy`` and ``-E copy_if_different`` command-line
|
* The :manual:`cmake(1)` ``-E copy`` and ``-E copy_if_different`` command-line
|
||||||
tools learned to support copying multiple input files to a directory.
|
tools learned to support copying multiple input files to a directory.
|
||||||
|
|
||||||
|
* The :manual:`cmake(1)` ``-E copy_directory`` command-line
|
||||||
|
tool learned to support copying multiple input directories to a directory.
|
||||||
|
|
|
@ -58,8 +58,8 @@ void CMakeCommandUsage(const char* program)
|
||||||
<< " compare_files file1 file2 - check if file1 is same as file2\n"
|
<< " compare_files file1 file2 - check if file1 is same as file2\n"
|
||||||
<< " copy <file>... destination - copy files to destination "
|
<< " copy <file>... destination - copy files to destination "
|
||||||
"(either file or directory)\n"
|
"(either file or directory)\n"
|
||||||
<< " copy_directory source destination - copy directory 'source' "
|
<< " copy_directory <dir>... destination - copy content of <dir>... "
|
||||||
"content to directory 'destination'\n"
|
"directories to 'destination' directory\n"
|
||||||
<< " copy_if_different <file>... destination - copy files if it has "
|
<< " copy_if_different <file>... destination - copy files if it has "
|
||||||
"changed\n"
|
"changed\n"
|
||||||
<< " echo [<string>...] - displays arguments as text\n"
|
<< " echo [<string>...] - displays arguments as text\n"
|
||||||
|
@ -206,16 +206,22 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy directory content
|
// Copy directory content
|
||||||
if (args[1] == "copy_directory" && args.size() == 4)
|
if (args[1] == "copy_directory" && args.size() > 3)
|
||||||
{
|
{
|
||||||
if(!cmSystemTools::CopyADirectory(args[2], args[3]))
|
// If error occurs we want to continue copying next files.
|
||||||
|
bool return_value = 0;
|
||||||
|
for (std::string::size_type cc = 2; cc < args.size() - 1; cc ++)
|
||||||
{
|
{
|
||||||
std::cerr << "Error copying directory from \""
|
if(!cmSystemTools::CopyADirectory(args[cc].c_str(),
|
||||||
<< args[2] << "\" to \"" << args[3]
|
args[args.size() - 1].c_str()))
|
||||||
<< "\".\n";
|
{
|
||||||
return 1;
|
std::cerr << "Error copying directory from \""
|
||||||
|
<< args[cc] << "\" to \"" << args[args.size() - 1]
|
||||||
|
<< "\".\n";
|
||||||
|
return_value = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename a file or directory
|
// Rename a file or directory
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,3 @@
|
||||||
|
^Error copying directory from .* to .*file_for_test.txt\".*
|
||||||
|
Error copying directory from .* to .*file_for_test.txt\".*
|
||||||
|
Error copying directory from .* to .*file_for_test.txt\".$
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
|
@ -124,6 +124,23 @@ run_cmake_command(E_copy_if_different-three-source-files-target-is-file
|
||||||
unset(in)
|
unset(in)
|
||||||
unset(out)
|
unset(out)
|
||||||
|
|
||||||
|
set(in ${RunCMake_SOURCE_DIR}/copy_input)
|
||||||
|
set(out ${RunCMake_BINARY_DIR}/copy_directory_output)
|
||||||
|
set(outfile ${out}/file_for_test.txt)
|
||||||
|
file(REMOVE_RECURSE "${out}")
|
||||||
|
file(MAKE_DIRECTORY ${out})
|
||||||
|
file(WRITE ${outfile} "")
|
||||||
|
run_cmake_command(E_copy_directory-three-source-files-target-is-directory
|
||||||
|
${CMAKE_COMMAND} -E copy_directory ${in}/d1 ${in}/d2 ${in}/d3 ${out})
|
||||||
|
run_cmake_command(E_copy_directory-three-source-files-target-is-file
|
||||||
|
${CMAKE_COMMAND} -E copy_directory ${in}/d1 ${in}/d2 ${in}/d3 ${outfile})
|
||||||
|
run_cmake_command(E_copy_directory-three-source-files-target-is-not-exist
|
||||||
|
${CMAKE_COMMAND} -E copy_directory ${in}/d1 ${in}/d2 ${in}/d3 ${out}/not_existing_directory)
|
||||||
|
unset(in)
|
||||||
|
unset(out)
|
||||||
|
unset(outfile)
|
||||||
|
|
||||||
|
|
||||||
run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env)
|
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)
|
run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1)
|
||||||
run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1)
|
run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1)
|
||||||
|
|
Loading…
Reference in New Issue