Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
On 12/04/2015 09:18 AM, Bartosz Kosiorek wrote: > Finally I manage to add wildcard support. > I have taken SimpleGlob.h library from: > https://github.com/brofield/simpleopt We don't want to do wildcard expansion in CMake commands. We want to leave it up to the shell to expand wildcards on the command line, or have explicit file(GLOB) commands in CMake script code. I've applied the patches from the previous post, with a slightly different breakdown and some fixes to the test: cmake: Improve '-E' help message formatting https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0be5020b cmake: Teach -E copy[_if_different] to support multiple files (#15703) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=384ae551 Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
Thanks Brad. Unfortunately we cannot use file(GLOB), because it is executed during generate step, and we would like to copy files which is created during Build step. Currently for filtering these files, we are using "cmake -E tar" to filter these files (so it packing and upacking). I think it is awful solution, but I cannot find better. What would you propose in that case? Is it possible to introduce "cmake -E list" command with wildcard support, to be able to filter files/directories, during Build step? The we couid use it to "cmake -E copy" command Best Regards Bartosz 2015-12-04 16:35 GMT+01:00 Brad King: > On 12/04/2015 09:18 AM, Bartosz Kosiorek wrote: > > Finally I manage to add wildcard support. > > I have taken SimpleGlob.h library from: > > https://github.com/brofield/simpleopt > > We don't want to do wildcard expansion in CMake commands. We want to leave > it up to the shell to expand wildcards on the command line, or have > explicit > file(GLOB) commands in CMake script code. > > I've applied the patches from the previous post, with a slightly > different breakdown and some fixes to the test: > > cmake: Improve '-E' help message formatting > https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0be5020b > > cmake: Teach -E copy[_if_different] to support multiple files (#15703) > https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=384ae551 > > Thanks, > -Brad > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
On 12/04/2015 11:15 AM, Bartosz Kosiorek wrote: > we cannot use file(GLOB), because it is executed during generate step, > and we would like to copy files which is created during Build step. The custom commands always execute inside a shell that can do glob expansion. Alternatively, use a "cmake -P myscript.cmake" to script the copy with e.g. file(COPY) optionally with file(GLOB). Generally we don't recommend globbing because it can accidentally get stale files. If you are creating files during the build step, don't you know what files are being created? -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
On 12/02/2015 07:05 PM, Bartosz Kosiorek wrote: > This patch allows to use multiple files in commands "copy" and > "copy_if_different". Good, thanks. Please also extend the Tests/RunCMake/CommandLine test to cover this these operations. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
On 12/03/2015 11:05 AM, Bartosz Kosiorek wrote: > After every step I will need to clean it up . If you add these as cases in the RunCMake.CommandLine test then each one can get its own directory and the RunCMake infrastructure will take care of cleaning it up for each run. -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
When I'm trying to run test with wildcard: run_cmake_command(E_copy-wildcard-source-files-target-is-directory ${CMAKE_COMMAND} -E copy ${RunCMake_copy_TEST_SOURCE_DIR}/directory1/* ${RunCMake_copy_TEST_BINARY_DIR}) I've got an error: Error copying file "/home/kosiorek/dev/perforce/cmake-dev/Tests/RunCMake/CommandLine/test_copy_command_dir/directory1/*" to "/home/kosiorek/dev/perforce/cmake-dev/builddir/Tests/RunCMake/CommandLine/test_copy_command_dir". but when I'm running such command locally it work perfectly: /home/kosiorek/dev/perforce/cmake-dev/builddir/bin/cmake -E copy /home/kosiorek/dev/perforce/cmake-dev/Tests/RunCMake/CommandLine/test_copy_command_dir/directory1/* /home/kosiorek/dev/perforce/cmake-dev/builddir/Tests/RunCMake/CommandLine/test_copy_command_dir What I'm doing wrong ? From: Brad King <brad.k...@kitware.com> Sent: Thursday, December 3, 2015 5:38 PM To: Bartosz Kosiorek Cc: cmake-developers@cmake.org Subject: Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files On 12/03/2015 11:05 AM, Bartosz Kosiorek wrote: > After every step I will need to clean it up . If you add these as cases in the RunCMake.CommandLine test then each one can get its own directory and the RunCMake infrastructure will take care of cleaning it up for each run. -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
Hi. I would like to create following tests for copy and copy_if_different commands: cmake -E copy test_copy_command_dir/file1.txt test_copy_command_dir/target_directory1 Result: success E_copy-one-source-directory-target-is-directory-result.txt E_copy-one-source-directory-target-is-directory-stderr.txt cmake -E copy test_copy_command_dir/directory1/file4.txt Result: error E_copy-one-source-file-result.txt E_copy-one-source-file-stderr.txt cmake -E copy test_copy_command_dir/file1.txt test_copy_command_dir/file2.txt test_copy_command_dir/file3.txt test_copy_command_dir/target_directory2 Result: Success E_copy-three-source-files-target-is-directory-result.txt E_copy-three-source-files-target-is-directory-stderr.txt cmake -E copy test_copy_command_dir/file1.txt test_copy_command_dir/file2.txt test_copy_command_dir/file3.txt test_copy_command_dir/target_directory1/file4.txt Result: Error E_copy-three-source-files-target-is-file-result.txt E_copy-three-source-files-target-is-file-stderr.txt cmake -E copy test_copy_command_dir/file1.txt not_existing_file.bad test_copy_command_dir/file2.txt test_copy_command_dir/target_directory3 Result: Error. The correct files are copied successfuly E_copy-two-good-and-one-bad-source-files-target-is-directory-result.txt E_copy-two-good-and-one-bad-source-files-target-is-directory-stderr.txt cmake -E copy test_copy_command_dir/*.txt test_copy_command_dir/target_directory4 Result: Success E_copy-wildcard-source-files-target-is-directory-result.txt E_copy-wildcard-source-files-target-is-directory-stderr.txt cmake -E copy test_copy_command_dir/* test_copy_command_dir/directory1/file4.txt Result: Error E_copy-wildcard-source-files-target-is-file-result.txt E_copy-wildcard-source-files-target-is-file-stderr.txt The resource directory will be: test_copy_command_dir ├── directory1 │ ├── file4.txt │ └── file5.txt ├── directory2 ├── file1.txt ├── file2.txt ├── file3.txt ├── target_directory1 ├── target_directory2 ├── target_directory3 └── target_directory4 What do you think about that? After every step I will need to clean it up . From: cmake-developers <cmake-developers-boun...@cmake.org> on behalf of Brad King <brad.k...@kitware.com> Sent: Thursday, December 3, 2015 2:45 PM To: cmake-developers@cmake.org Subject: Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files On 12/02/2015 07:05 PM, Bartosz Kosiorek wrote: > This patch allows to use multiple files in commands "copy" and > "copy_if_different". Good, thanks. Please also extend the Tests/RunCMake/CommandLine test to cover this these operations. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
Hello. Here is the patch with tests. From: Brad King <brad.k...@kitware.com> Sent: Thursday, December 3, 2015 7:07 PM To: Bartosz Kosiorek Cc: cmake-developers@cmake.org Subject: Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files On 12/03/2015 12:31 PM, Bartosz Kosiorek wrote: > When I'm trying to run test with wildcard: > run_cmake_command(E_copy-wildcard-source-files-target-is-directory > ${CMAKE_COMMAND} -E copy > ${RunCMake_copy_TEST_SOURCE_DIR}/directory1/* > ${RunCMake_copy_TEST_BINARY_DIR}) > > I've got an error: The command is not running through a shell in that case so there is no step that expands the wildcard. This feature is not about wildcard expansion, but about multiple inputs to the copy. They can be spelled out explicitly in the command invocation, or passed through a variable containing a list populated by file(GLOB). -Brad From 8225688074386ac8633bad5e6f9fdb4a7caf9775 Mon Sep 17 00:00:00 2001 From: "Bartosz Kosiorek bartosz.kosio...@tomtom.com" <bartosz.kosio...@tomtom.com> Date: Thu, 3 Dec 2015 00:43:37 +0100 Subject: [PATCH 1/2] Extend copy and copy_if_different command with support multiple files This patch allows to use multiple files in command copy and copy_if_different. Input files could be merged with wildcards. If multipile input files were provided, then destination must be directory. If only one input file was provided, then destination could be either file or directory. This path is starting point for fixing bug 15703 --- Help/manual/cmake.1.rst | 12 Source/cmcmd.cxx| 73 +++-- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index dac16bf..086f259 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -169,14 +169,14 @@ Available commands are: ``compare_files `` Check if file1 is same as file2. -``copy `` - Copy file to destination (either file or directory). +``copy ... `` + Copy files to 'destination' (either file or directory). ``copy_directory `` Copy directory 'source' content to directory 'destination'. -``copy_if_different `` - Copy file if input has changed. +``copy_if_different ... `` + Copy files if input has changed. Destination could be file or directory. ``echo [...]`` Displays arguments as text. @@ -193,10 +193,10 @@ Available commands are: ``make_directory `` Create a directory. -``md5sum [...]`` +``md5sum ...`` Compute md5sum of files. -``remove [-f] [...]`` +``remove [-f] ...`` Remove the file(s), use ``-f`` to force it. ``remove_directory `` diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 21b126b..0dc5a9a 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -52,25 +52,25 @@ void CMakeCommandUsage(const char* program) // If you add new commands, change here, // and in cmakemain.cxx in the options table errorStream -<< "Usage: " << program << " -E [command] [arguments ...]\n" +<< "Usage: " << program << " -E [arguments...]\n" << "Available commands: \n" << " chdir dir cmd [args]... - run command in a given directory\n" << " compare_files file1 file2 - check if file1 is same as file2\n" -<< " copy file destination - copy file to destination (either file " - "or directory)\n" +<< " copy ... destination - copy files to destination " + "(either file or directory)\n" << " copy_directory source destination - copy directory 'source' " "content to directory 'destination'\n" -<< " copy_if_different in-file out-file - copy file if input has " +<< " copy_if_different ... destination - copy files if it has " "changed\n" -<< " echo [string]... - displays arguments as text\n" -<< " echo_append [string]... - displays arguments as text but no new " +<< " echo [...]- displays arguments as text\n" +<< " echo_append [...] - displays arguments as text but no new " "line\n" << " 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" -<< " md5sum file1 [...]- compute md5sum of files\n" -<< " remove [-f] file1 file2 ... -
Re: [cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
On 12/03/2015 12:31 PM, Bartosz Kosiorek wrote: > When I'm trying to run test with wildcard: > run_cmake_command(E_copy-wildcard-source-files-target-is-directory > ${CMAKE_COMMAND} -E copy > ${RunCMake_copy_TEST_SOURCE_DIR}/directory1/* > ${RunCMake_copy_TEST_BINARY_DIR}) > > I've got an error: The command is not running through a shell in that case so there is no step that expands the wildcard. This feature is not about wildcard expansion, but about multiple inputs to the copy. They can be spelled out explicitly in the command invocation, or passed through a variable containing a list populated by file(GLOB). -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
[cmake-developers] [PATCH] Extend copy and copy_if_different commands with support multiple files
Hi. This patch allows to use multiple files in commands "copy" and "copy_if_different". Input files could be merged with wildcards. For example: ./bin/cmake -E copy bin/* CMakeFiles/* file.tar dupajasia If wrong file path were provided as input then the error will be displayed, but rest of the files will be copied. For example: ./bin/cmake -E copy bin/* CMakeFiles/* wrong_file file.tar dupajasia/ Error copying file "wrong_file" to "dupajasia/". If multipile input files were provided, then destination must be directory. Example: ./bin/cmake -E copy bin/* CMakeFiles/* wrong_file file.tar dupajasia/ctest Error: Target (copy) "dupajasia/ctest" is not a directory. ./bin/cmake -E copy bin/* dupajasia/ctest? Error: Target (copy) "dupajasia/ctest?" is not a directory. If only one input file was provided, then destination could be either file or directory: ./bin/cmake -E copy file.tar dupajasia/ctest This path is starting point for fixing bug 15703: ?https://public.kitware.com/Bug/view.php?id=15703 Best Regards Bartosz From 8225688074386ac8633bad5e6f9fdb4a7caf9775 Mon Sep 17 00:00:00 2001 From: "Bartosz Kosiorek bartosz.kosio...@tomtom.com"Date: Thu, 3 Dec 2015 00:43:37 +0100 Subject: [PATCH] Extend copy and copy_if_different command with support multiple files This patch allows to use multiple files in command copy and copy_if_different. Input files could be merged with wildcards. If multipile input files were provided, then destination must be directory. If only one input file was provided, then destination could be either file or directory. This path is starting point for fixing bug 15703 --- Help/manual/cmake.1.rst | 12 Source/cmcmd.cxx| 73 +++-- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index dac16bf..086f259 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -169,14 +169,14 @@ Available commands are: ``compare_files `` Check if file1 is same as file2. -``copy `` - Copy file to destination (either file or directory). +``copy ... `` + Copy files to 'destination' (either file or directory). ``copy_directory `` Copy directory 'source' content to directory 'destination'. -``copy_if_different `` - Copy file if input has changed. +``copy_if_different ... `` + Copy files if input has changed. Destination could be file or directory. ``echo [...]`` Displays arguments as text. @@ -193,10 +193,10 @@ Available commands are: ``make_directory `` Create a directory. -``md5sum [...]`` +``md5sum ...`` Compute md5sum of files. -``remove [-f] [...]`` +``remove [-f] ...`` Remove the file(s), use ``-f`` to force it. ``remove_directory `` diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 21b126b..0dc5a9a 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -52,25 +52,25 @@ void CMakeCommandUsage(const char* program) // If you add new commands, change here, // and in cmakemain.cxx in the options table errorStream -<< "Usage: " << program << " -E [command] [arguments ...]\n" +<< "Usage: " << program << " -E [arguments...]\n" << "Available commands: \n" << " chdir dir cmd [args]... - run command in a given directory\n" << " compare_files file1 file2 - check if file1 is same as file2\n" -<< " copy file destination - copy file to destination (either file " - "or directory)\n" +<< " copy ... destination - copy files to destination " + "(either file or directory)\n" << " copy_directory source destination - copy directory 'source' " "content to directory 'destination'\n" -<< " copy_if_different in-file out-file - copy file if input has " +<< " copy_if_different ... destination - copy files if it has " "changed\n" -<< " echo [string]... - displays arguments as text\n" -<< " echo_append [string]... - displays arguments as text but no new " +<< " echo [...]- displays arguments as text\n" +<< " echo_append [...] - displays arguments as text but no new " "line\n" << " 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" -<< " md5sum file1 [...]- compute md5sum of files\n" -<< " remove [-f] file1 file2 ... - remove the file(s), use -f to force " +<< " md5sum ... - compute md5sum of files\n" +<< " remove [-f] ... - remove the file(s), use -f to force " "it\n" << " remove_directory dir - remove a directory and its contents\n" << " rename oldname newname- rename a file or directory " @@ -78,7 +78,7 @@ void