cmake: Teach -E make_directory to support multiple input directories
This commit is contained in:
parent
4ce6fbc76b
commit
7984ac5e58
|
@ -167,7 +167,8 @@ Available commands are:
|
|||
Change the current working directory and run a command.
|
||||
|
||||
``compare_files <file1> <file2>``
|
||||
Check if file1 is same as file2.
|
||||
Check if ``<file1>`` is same as ``<file2>``. If files are the same,
|
||||
then returns 0, if not itreturns 1.
|
||||
|
||||
``copy <file>... <destination>``
|
||||
Copy files to ``<destination>`` (either file or directory).
|
||||
|
@ -194,10 +195,11 @@ Available commands are:
|
|||
Run command in a modified environment.
|
||||
|
||||
``environment``
|
||||
Display the current environment.
|
||||
Display the current environment variables.
|
||||
|
||||
``make_directory <dir>``
|
||||
Create a directory.
|
||||
``make_directory <dir>...``
|
||||
Create ``<dir>`` directories. If necessary, create parent
|
||||
directories too.
|
||||
|
||||
``md5sum <file>...``
|
||||
Compute md5sum of files.
|
||||
|
|
|
@ -6,3 +6,6 @@ cmake-E-multiple-inputs
|
|||
|
||||
* The :manual:`cmake(1)` ``-E copy_directory`` command-line
|
||||
tool learned to support copying multiple input directories to a directory.
|
||||
|
||||
* The :manual:`cmake(1)` ``-E make_directory`` command-line
|
||||
tool learned to support copying multiple input directories to a directory.
|
||||
|
|
|
@ -68,7 +68,7 @@ void CMakeCommandUsage(const char* program)
|
|||
<< " env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...\n"
|
||||
<< " - run command in a modified environment\n"
|
||||
<< " environment - display the current environment\n"
|
||||
<< " make_directory dir - create a directory\n"
|
||||
<< " make_directory <dir>... - create parent and <dir> directories\n"
|
||||
<< " md5sum <file>... - compute md5sum of files\n"
|
||||
<< " remove [-f] <file>... - remove the file(s), use -f to force "
|
||||
"it\n"
|
||||
|
@ -447,15 +447,20 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||
}
|
||||
#endif
|
||||
|
||||
else if (args[1] == "make_directory" && args.size() == 3)
|
||||
else if (args[1] == "make_directory" && args.size() > 2)
|
||||
{
|
||||
if(!cmSystemTools::MakeDirectory(args[2].c_str()))
|
||||
// If error occurs we want to continue copying next files.
|
||||
bool return_value = 0;
|
||||
for (std::string::size_type cc = 2; cc < args.size(); cc ++)
|
||||
{
|
||||
std::cerr << "Error making directory \"" << args[2]
|
||||
<< "\".\n";
|
||||
return 1;
|
||||
if(!cmSystemTools::MakeDirectory(args[cc].c_str()))
|
||||
{
|
||||
std::cerr << "Error creating directory \""
|
||||
<< args[cc] << "\".\n";
|
||||
return_value = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
else if (args[1] == "remove_directory" && args.size() == 3)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1 @@
|
|||
^Error creating directory .*file_for_test.txt\".$
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -140,6 +140,20 @@ unset(in)
|
|||
unset(out)
|
||||
unset(outfile)
|
||||
|
||||
set(out ${RunCMake_BINARY_DIR}/make_directory_output)
|
||||
set(outfile ${out}/file_for_test.txt)
|
||||
file(REMOVE_RECURSE "${out}")
|
||||
file(MAKE_DIRECTORY ${out})
|
||||
file(WRITE ${outfile} "")
|
||||
run_cmake_command(E_make_directory-three-directories
|
||||
${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${out}/d2)
|
||||
run_cmake_command(E_make_directory-directory-with-parent
|
||||
${CMAKE_COMMAND} -E make_directory ${out}/parent/child)
|
||||
run_cmake_command(E_make_directory-three-directories-and-file
|
||||
${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${outfile})
|
||||
unset(out)
|
||||
unset(outfile)
|
||||
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue