From 29dcbe416930da17f20d79b7f9787ea8bfe5c370 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 14 Feb 2026 13:05:42 -0500 Subject: [PATCH 1/2] cmake -E copy_if_*: Add -t argument support Issue: #24568 --- Help/manual/cmake.1.rst | 22 +++-- Help/release/dev/cmake-E-copy-t-flag.rst | 7 ++ Source/cmcmd.cxx | 96 +++++++------------ ...erent-t-argument-target-is-file-result.txt | 1 + ...erent-t-argument-target-is-file-stderr.txt | 1 + ...newer-t-argument-target-is-file-result.txt | 1 + ...newer-t-argument-target-is-file-stderr.txt | 1 + Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 12 +++ 8 files changed, 71 insertions(+), 70 deletions(-) create mode 100644 Help/release/dev/cmake-E-copy-t-flag.rst create mode 100644 Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-result.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-result.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-stderr.txt diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index f31ef43e8d..fd2f953f6b 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -1222,7 +1222,7 @@ Available commands are: Copy files to ```` (either file or directory). If multiple files are specified, or if ``-t`` is specified, the - ```` must be directory and it must exist. If ``-t`` is not + ```` must be a directory and it must exist. If ``-t`` is not specified, the last argument is assumed to be the ````. Wildcards are not supported. ``copy`` does follow symlinks. That means it does not copy symlinks, but the files or directories it point to. @@ -1269,29 +1269,37 @@ Available commands are: This is faster than ``copy_directory_if_different`` as it only compares file timestamps instead of file contents. -.. option:: copy_if_different ... +.. option:: copy_if_different ... , + copy_if_different -t ... Copy files to ```` (either file or directory) if they have changed. - If multiple files are specified, the ```` must be - directory and it must exist. + If multiple files are specified, or if ``-t`` is specified, + the ```` must be a directory and it must exist. ``copy_if_different`` does follow symlinks. .. versionadded:: 3.5 Support for multiple input files. -.. option:: copy_if_newer ... + .. versionadded:: 4.4 + Support for the ``-t`` argument. + +.. option:: copy_if_newer ... , + copy_if_newer -t ... .. versionadded:: 4.2 Copy files to ```` (either file or directory) if source files are newer than destination files (based on file timestamps). - If multiple files are specified, the ```` must be - directory and it must exist. + If multiple files are specified, or if ``-t`` is specified, + the ```` must be a directory and it must exist. ``copy_if_newer`` does follow symlinks. This is faster than ``copy_if_different`` as it only compares file timestamps instead of file contents. + .. versionadded:: 4.4 + Support for the ``-t`` argument. + .. option:: create_symlink Create a symbolic link ```` naming ````. diff --git a/Help/release/dev/cmake-E-copy-t-flag.rst b/Help/release/dev/cmake-E-copy-t-flag.rst new file mode 100644 index 0000000000..8cf32646bb --- /dev/null +++ b/Help/release/dev/cmake-E-copy-t-flag.rst @@ -0,0 +1,7 @@ +cmake-E-copy-t-flag +------------------- + +* The :option:`cmake -E` commands + :option:`copy_if_different ` and + :option:`copy_if_newer ` + gained support for the ``-t`` argument. diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 4b08d00484..7e88103d19 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -105,13 +105,16 @@ char const* const HELP_AVAILABLE_COMMANDS = R"(Available commands: cat [--] ... - concat the files and print them to the standard output chdir dir cmd [args...] - run command in a given directory compare_files [--ignore-eol] file1 file2 - - check if file1 is same as file2 - copy ... destination - copy files to destination (either file or directory) + - check if file1 is same as file2 + copy ... destination | -t ... + - copy files to destination (either file or directory) copy_directory ... destination - copy content of ... directories to 'destination' directory copy_directory_if_different ... destination - copy changed content of ... directories to 'destination' directory copy_directory_if_newer ... destination - copy newer content of ... directories to 'destination' directory - copy_if_different ... destination - copy files if it has changed - copy_if_newer ... destination - copy files if source is newer than destination + copy_if_different ... destination | -t ... + - copy files if source has changed + copy_if_newer ... destination | -t ... + - copy files if source is newer than destination echo [...] - displays arguments as text echo_append [...] - displays arguments as text but no new line env [--unset=NAME ...] [NAME=VALUE ...] [--] [...] @@ -1002,8 +1005,26 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, { // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx if (args.size() > 1) { - // Copy file - if (args[1] == "copy" && args.size() > 3) { + // Copy file, copy file if different, copy file if newer. + if ((args[1] == "copy" || args[1] == "copy_if_different" || + args[1] == "copy_if_newer") && + args.size() > 3) { + using CopyFn = cmsys::SystemTools::CopyStatus (*)(std::string const&, + std::string const&); + CopyFn copyFn; + std::string copyErrPrefix; + if (args[1] == "copy") { + copyFn = cmSystemTools::CopyFileAlways; + copyErrPrefix = "Error copying file"; + } else if (args[1] == "copy_if_different") { + copyFn = cmSystemTools::CopyFileIfDifferent; + copyErrPrefix = "Error copying file (if different) from"; + } else { + copyFn = cmSystemTools::CopyFileIfNewer; + copyErrPrefix = "Error copying file (if newer) from"; + } + std::string const& cmdName = args[1]; + using CommandArgument = cmCommandLineArgument; @@ -1038,14 +1059,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, files.pop_back(); } if (targetArg && (!cmSystemTools::FileIsDirectory(*targetArg))) { - std::cerr << "Error: Target (for copy command) \"" << *targetArg - << "\" is not a directory.\n"; + std::cerr << "Error: Target (for " << cmdName << " command) \"" + << *targetArg << "\" is not a directory.\n"; return 1; } if (!targetArg) { if (files.size() < 2) { - std::cerr - << "Error: No files or target specified (for copy command).\n"; + std::cerr << "Error: No files or target specified (for " << cmdName + << " command).\n"; return 1; } targetArg = files.back(); @@ -1054,10 +1075,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // If error occurs we want to continue copying next files. bool return_value = false; for (auto const& file : files) { - cmsys::SystemTools::CopyStatus const status = - cmSystemTools::CopyFileAlways(file, *targetArg); + cmsys::SystemTools::CopyStatus const status = copyFn(file, *targetArg); if (!status) { - std::cerr << "Error copying file \"" << file << "\" to \"" + std::cerr << copyErrPrefix << " \"" << file << "\" to \"" << *targetArg << "\": " << status.GetString() << '\n'; return_value = true; } @@ -1065,56 +1085,6 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, return return_value; } - // Copy file if different. - if (args[1] == "copy_if_different" && args.size() > 3) { - // If multiple source files specified, - // then destination must be directory - if ((args.size() > 4) && - (!cmSystemTools::FileIsDirectory(args.back()))) { - std::cerr << "Error: Target (for copy_if_different command) \"" - << args.back() << "\" is not a directory.\n"; - return 1; - } - // If error occurs we want to continue copying next files. - bool return_value = false; - for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { - cmsys::SystemTools::CopyStatus const status = - cmSystemTools::CopyFileIfDifferent(arg, args.back()); - if (!status) { - std::cerr << "Error copying file (if different) from \"" << arg - << "\" to \"" << args.back() - << "\": " << status.GetString() << '\n'; - return_value = true; - } - } - return return_value; - } - - // Copy file if newer. - if (args[1] == "copy_if_newer" && args.size() > 3) { - // If multiple source files specified, - // then destination must be directory - if ((args.size() > 4) && - (!cmSystemTools::FileIsDirectory(args.back()))) { - std::cerr << "Error: Target (for copy_if_newer command) \"" - << args.back() << "\" is not a directory.\n"; - return 1; - } - // If error occurs we want to continue copying next files. - bool return_value = false; - for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { - cmsys::SystemTools::CopyStatus const status = - cmSystemTools::CopyFileIfNewer(arg, args.back()); - if (!status) { - std::cerr << "Error copying file (if newer) from \"" << arg - << "\" to \"" << args.back() - << "\": " << status.GetString() << '\n'; - return_value = true; - } - } - return return_value; - } - // Copy directory contents if ((args[1] == "copy_directory" || args[1] == "copy_directory_if_different" || diff --git a/Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-result.txt b/Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-stderr.txt new file mode 100644 index 0000000000..138ce8136d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_if_different-t-argument-target-is-file-stderr.txt @@ -0,0 +1 @@ +^Error: Target \(for copy_if_different command\).* is not a directory\.$ diff --git a/Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-result.txt b/Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-stderr.txt new file mode 100644 index 0000000000..08eab4ca14 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_if_newer-t-argument-target-is-file-stderr.txt @@ -0,0 +1 @@ +^Error: Target \(for copy_if_newer command\).* is not a directory\.$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index b54a01ac1a..7dc26ed797 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -653,6 +653,12 @@ run_cmake_command(E_copy-t-argument-target-is-file ${CMAKE_COMMAND} -E copy ${in}/f1.txt -t ${out}/f1.txt ${in}/f3.txt) run_cmake_command(E_copy-t-argument-no-source-files ${CMAKE_COMMAND} -E copy -t ${out}) +run_cmake_command(E_copy_if_different-t-argument + ${CMAKE_COMMAND} -E copy_if_different ${in}/f1.txt -t ${out} ${in}/f3.txt) +run_cmake_command(E_copy_if_different-t-argument-target-is-file + ${CMAKE_COMMAND} -E copy_if_different ${in}/f1.txt -t ${out}/f1.txt ${in}/f3.txt) +run_cmake_command(E_copy_if_different-t-argument-no-source-files + ${CMAKE_COMMAND} -E copy_if_different -t ${out}) run_cmake_command(E_copy_if_different-one-source-directory-target-is-directory ${CMAKE_COMMAND} -E copy_if_different ${in}/f1.txt ${out}) run_cmake_command(E_copy_if_different-three-source-files-target-is-directory @@ -661,6 +667,12 @@ run_cmake_command(E_copy_if_different-three-source-files-target-is-file ${CMAKE_COMMAND} -E copy_if_different ${in}/f1.txt ${in}/f2.txt ${in}/f3.txt ${out}/f1.txt) run_cmake_command(E_copy_if_different-nonexistent-source ${CMAKE_COMMAND} -E copy_if_different ${in}/nonexistent.txt ${out}) +run_cmake_command(E_copy_if_newer-t-argument + ${CMAKE_COMMAND} -E copy_if_newer ${in}/f1.txt -t ${out} ${in}/f3.txt) +run_cmake_command(E_copy_if_newer-t-argument-target-is-file + ${CMAKE_COMMAND} -E copy_if_newer ${in}/f1.txt -t ${out}/f1.txt ${in}/f3.txt) +run_cmake_command(E_copy_if_newer-t-argument-no-source-files + ${CMAKE_COMMAND} -E copy_if_newer -t ${out}) run_cmake_command(E_copy_if_newer-one-source-directory-target-is-directory ${CMAKE_COMMAND} -E copy_if_newer ${in}/f1.txt ${out}) run_cmake_command(E_copy_if_newer-three-source-files-target-is-directory From 16b8a1ba2aad15d79c15087b789d9a594beebeed Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 16 Feb 2026 23:40:56 -0500 Subject: [PATCH 2/2] cmake -E copy_directory*: Add -t argument support Fixes: #24568 --- Help/manual/cmake.1.rst | 39 +++++++--- Help/release/dev/cmake-E-copy-t-flag.rst | 7 +- Source/cmcmd.cxx | 72 +++++++++++++++---- ...ctory-t-argument-no-source-dirs-result.txt | 1 + ...ctory-t-argument-no-source-dirs-stderr.txt | 1 + ...erent-t-argument-no-source-dirs-result.txt | 1 + ...erent-t-argument-no-source-dirs-stderr.txt | 1 + ...newer-t-argument-no-source-dirs-result.txt | 1 + ...newer-t-argument-no-source-dirs-stderr.txt | 1 + Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 12 ++++ 10 files changed, 110 insertions(+), 26 deletions(-) create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-result.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-result.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-result.txt create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-stderr.txt diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index fd2f953f6b..6683e71dba 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -1218,7 +1218,8 @@ Available commands are: .. program:: cmake-E -.. option:: copy ... , copy -t ... +.. option:: copy ... , + copy -t ... Copy files to ```` (either file or directory). If multiple files are specified, or if ``-t`` is specified, the @@ -1233,10 +1234,13 @@ Available commands are: .. versionadded:: 3.26 Support for ``-t`` argument. -.. option:: copy_directory ... +.. option:: copy_directory ... , + copy_directory -t ... - Copy content of ``...`` directories to ```` directory. - If ```` directory does not exist it will be created. + Copy content of ``...`` directories to a ```` directory. + If the ```` directory does not exist it will be created. + If ``-t`` is not specified, the last argument is assumed to be the + ````. ``copy_directory`` does follow symlinks. .. versionadded:: 3.5 @@ -1246,29 +1250,44 @@ Available commands are: The command now fails when the source directory does not exist. Previously it succeeded by creating an empty destination directory. -.. option:: copy_directory_if_different ... + .. versionadded:: 4.4 + Support for the ``-t`` argument. + +.. option:: copy_directory_if_different ... , + copy_directory_if_different -t ... .. versionadded:: 3.26 - Copy changed content of ``...`` directories to ```` directory. - If ```` directory does not exist it will be created. + Copy changed content of ``...`` directories to a ```` directory. + If the ```` directory does not exist it will be created. + If ``-t`` is not specified, the last argument is assumed to be the + ````. ``copy_directory_if_different`` does follow symlinks. The command fails when the source directory does not exist. -.. option:: copy_directory_if_newer ... + .. versionadded:: 4.4 + Support for the ``-t`` argument. + +.. option:: copy_directory_if_newer ... , + copy_directory_if_newer -t ... .. versionadded:: 4.2 - Copy content of ``...`` directories to ```` directory + Copy content of ``...`` directories to a ```` directory if source files are newer than destination files (based on file timestamps). - If ```` directory does not exist it will be created. + If the ```` directory does not exist it will be created. + If ``-t`` is not specified, the last argument is assumed to be the + ````. ``copy_directory_if_newer`` does follow symlinks. The command fails when the source directory does not exist. This is faster than ``copy_directory_if_different`` as it only compares file timestamps instead of file contents. + .. versionadded:: 4.4 + Support for the ``-t`` argument. + .. option:: copy_if_different ... , copy_if_different -t ... diff --git a/Help/release/dev/cmake-E-copy-t-flag.rst b/Help/release/dev/cmake-E-copy-t-flag.rst index 8cf32646bb..178292cc68 100644 --- a/Help/release/dev/cmake-E-copy-t-flag.rst +++ b/Help/release/dev/cmake-E-copy-t-flag.rst @@ -2,6 +2,9 @@ cmake-E-copy-t-flag ------------------- * The :option:`cmake -E` commands - :option:`copy_if_different ` and - :option:`copy_if_newer ` + :option:`copy_if_different `, + :option:`copy_if_newer `, + :option:`copy_directory `, + :option:`copy_directory_if_different `, + and :option:`copy_directory_if_newer ` gained support for the ``-t`` argument. diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 7e88103d19..2f9f9528d3 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -108,9 +108,12 @@ char const* const HELP_AVAILABLE_COMMANDS = R"(Available commands: - check if file1 is same as file2 copy ... destination | -t ... - copy files to destination (either file or directory) - copy_directory ... destination - copy content of ... directories to 'destination' directory - copy_directory_if_different ... destination - copy changed content of ... directories to 'destination' directory - copy_directory_if_newer ... destination - copy newer content of ... directories to 'destination' directory + copy_directory ... destination | -t ... + - copy content of ... directories to 'destination' directory + copy_directory_if_different ... destination | -t ... + - copy changed content of ... directories to 'destination' directory + copy_directory_if_newer ... destination | -t ... + - copy newer content of ... directories to 'destination' directory copy_if_different ... destination | -t ... - copy files if source has changed copy_if_newer ... destination | -t ... @@ -1086,26 +1089,67 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, } // Copy directory contents - if ((args[1] == "copy_directory" || - args[1] == "copy_directory_if_different" || - args[1] == "copy_directory_if_newer") && - args.size() > 3) { - // If error occurs we want to continue copying next files. - bool return_value = false; - + if (args[1] == "copy_directory" || + args[1] == "copy_directory_if_different" || + args[1] == "copy_directory_if_newer") { cmsys::SystemTools::CopyWhen when = cmsys::SystemTools::CopyWhen::Always; if (args[1] == "copy_directory_if_different") { when = cmsys::SystemTools::CopyWhen::OnlyIfDifferent; } else if (args[1] == "copy_directory_if_newer") { when = cmsys::SystemTools::CopyWhen::OnlyIfNewer; } + std::string const& cmdName = args[1]; - for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { + using CommandArgument = + cmCommandLineArgument; + + cm::optional targetArg; + std::vector argParsers{ + { "-t", CommandArgument::Values::One, + CommandArgument::setToValue(targetArg) }, + }; + + std::vector dirs; + for (decltype(args.size()) i = 2; i < args.size(); i++) { + std::string const& arg = args[i]; + bool matched = false; + for (auto const& m : argParsers) { + if (m.matches(arg)) { + matched = true; + if (m.parse(arg, i, args)) { + break; + } + return 1; // failed to parse + } + } + if (!matched) { + dirs.push_back(arg); + } + } + + if (!targetArg) { + if (dirs.size() < 2) { + std::cerr << "Error: No directories or target specified (for " + << cmdName << " command).\n"; + return 1; + } + targetArg = dirs.back(); + dirs.pop_back(); + } + if (dirs.empty()) { + std::cerr << "Error: No source directories specified (for " << cmdName + << " command).\n"; + return 1; + } + + // If error occurs we want to continue copying next files. + bool return_value = false; + for (auto const& dir : dirs) { cmsys::Status const status = - cmSystemTools::CopyADirectory(arg, args.back(), when); + cmSystemTools::CopyADirectory(dir, *targetArg, when); if (!status) { - std::cerr << "Error copying directory from \"" << arg << "\" to \"" - << args.back() << "\": " << status.GetString() << '\n'; + std::cerr << "Error copying directory from \"" << dir << "\" to \"" + << *targetArg << "\": " << status.GetString() << '\n'; return_value = true; } } diff --git a/Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-result.txt b/Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-stderr.txt new file mode 100644 index 0000000000..c3c3d6ae25 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_directory-t-argument-no-source-dirs-stderr.txt @@ -0,0 +1 @@ +^Error: No source directories specified \(for copy_directory command\)\.$ diff --git a/Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-result.txt b/Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-stderr.txt new file mode 100644 index 0000000000..371acbfe8e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_directory_if_different-t-argument-no-source-dirs-stderr.txt @@ -0,0 +1 @@ +^Error: No source directories specified \(for copy_directory_if_different command\)\.$ diff --git a/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-result.txt b/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-stderr.txt b/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-stderr.txt new file mode 100644 index 0000000000..9af85a8153 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_copy_directory_if_newer-t-argument-no-source-dirs-stderr.txt @@ -0,0 +1 @@ +^Error: No source directories specified \(for copy_directory_if_newer command\)\.$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 7dc26ed797..ec72bcdce7 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -690,8 +690,16 @@ file(REMOVE_RECURSE "${out}") file(MAKE_DIRECTORY ${out}) run_cmake_command(E_copy_directory_if_different ${CMAKE_COMMAND} -E copy_directory_if_different ${in} ${out}) +run_cmake_command(E_copy_directory_if_different-t-argument + ${CMAKE_COMMAND} -E copy_directory_if_different -t ${out} ${in}) +run_cmake_command(E_copy_directory_if_different-t-argument-no-source-dirs + ${CMAKE_COMMAND} -E copy_directory_if_different -t ${out}) run_cmake_command(E_copy_directory_if_newer ${CMAKE_COMMAND} -E copy_directory_if_newer ${in} ${out}) +run_cmake_command(E_copy_directory_if_newer-t-argument + ${CMAKE_COMMAND} -E copy_directory_if_newer -t ${out} ${in}) +run_cmake_command(E_copy_directory_if_newer-t-argument-no-source-dirs + ${CMAKE_COMMAND} -E copy_directory_if_newer -t ${out}) run_cmake_command(E_copy_directory_if_newer-nonexistent-source ${CMAKE_COMMAND} -E copy_directory_if_newer ${in}/nonexistent ${out}/target) unset(in) @@ -709,6 +717,10 @@ 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) +run_cmake_command(E_copy_directory-t-argument + ${CMAKE_COMMAND} -E copy_directory -t ${out} ${in}/d1 ${in}/d2 ${in}/d3) +run_cmake_command(E_copy_directory-t-argument-no-source-dirs + ${CMAKE_COMMAND} -E copy_directory -t ${out}) unset(in) unset(out) unset(outfile)