[cmake-developers] [PATCH] Add support for multiple parameters in cmake -E copy_directory command

2015-12-06 Thread Bartosz Kosiorek
Hello.


I following patch I have added support for multiple source directories into 
copy_directory command.


Comments are welcomed.


Best Regards

Bartosz
From 6ff0139ae43d4ac4a503007dd6abac5dcefd1083 Mon Sep 17 00:00:00 2001
From: Bartosz Kosiorek 
Date: Sun, 6 Dec 2015 20:30:44 +0100
Subject: [PATCH] Add support for multiple directory for "copy_directory"
 command

---
 Help/manual/cmake.1.rst| 11 +---
 Source/cmcmd.cxx   | 30 +-
 ...ree-source-files-target-is-directory-result.txt |  1 +
 ...ree-source-files-target-is-directory-stderr.txt |  0
 ...ry-three-source-files-target-is-file-result.txt |  1 +
 ...ry-three-source-files-target-is-file-stderr.txt |  3 +++
 ...ree-source-files-target-is-not-exist-result.txt |  1 +
 ...ree-source-files-target-is-not-exist-stderr.txt |  0
 Tests/RunCMake/CommandLine/RunCMakeTest.cmake  | 17 
 Tests/RunCMake/CommandLine/copy_input/d1/d1.txt|  0
 Tests/RunCMake/CommandLine/copy_input/d2/d2.txt|  0
 Tests/RunCMake/CommandLine/copy_input/d3/d3.txt|  0
 12 files changed, 49 insertions(+), 15 deletions(-)
 create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-directory-result.txt
 create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-directory-stderr.txt
 create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-file-result.txt
 create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-file-stderr.txt
 create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-not-exist-result.txt
 create mode 100644 Tests/RunCMake/CommandLine/E_copy_directory-three-source-files-target-is-not-exist-stderr.txt
 create mode 100644 Tests/RunCMake/CommandLine/copy_input/d1/d1.txt
 create mode 100644 Tests/RunCMake/CommandLine/copy_input/d2/d2.txt
 create mode 100644 Tests/RunCMake/CommandLine/copy_input/d3/d3.txt

diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 086f259..4156638 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -170,13 +170,18 @@ Available commands are:
   Check if file1 is same as file2.
 
 ``copy ... ``
-  Copy files to 'destination' (either file or directory).
+  Copy files to  (either file or directory).
+  If multiple files are specified, the  must be
+  directory and it must exists.
 
-``copy_directory  ``
-  Copy directory 'source' content to directory 'destination'.
+``copy_directory ... ``
+  Copy content of ... directories to  directory.
+  If  directory is not exist, then it will be created.
 
 ``copy_if_different ... ``
   Copy files if input has changed. Destination could be file or directory.
+  If multiple files are specified, the  must be
+  directory and it must exists.
 
 ``echo [...]``
   Displays arguments as text.
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 0dc5a9a..6a4234f 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -54,12 +54,12 @@ void CMakeCommandUsage(const char* program)
   errorStream
 << "Usage: " << program << " -E  [arguments...]\n"
 << "Available commands: \n"
-<< "  chdir dir cmd [args]...   - run command in a given directory\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 ... destination  - copy files to destination "
"(either file or directory)\n"
-<< "  copy_directory source destination   - copy directory 'source' "
-   "content to directory 'destination'\n"
+<< "  copy_directory ... destination   - copy content of ... "
+   "directories to 'destination' directory\n"
 << "  copy_if_different ... destination  - copy files if it has "
"changed\n"
 << "  echo [...]- displays arguments as text\n"
@@ -197,8 +197,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args)
 args[args.size() - 1].c_str()))
   {
   std::cerr << "Error copying file (if different) from \""
- << args[cc] << "\" to \"" << args[args.size() - 1]
- << "\".\n";
+<< args[cc] << "\" to \"" << args[args.size() - 1]
+<< "\".\n";
   return_value = 1;
   }
 }
@@ -206,16 +206,22 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args)
   }
 
 // 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 \""
-  << 

[cmake-developers] [CMake 0015872]: Programs with Fortran entry point (but calls into C) don't link correctly using Intel or PGI compilers

2015-12-06 Thread Mantis Bug Tracker

The following issue has been SUBMITTED. 
== 
https://public.kitware.com/Bug/view.php?id=15872 
== 
Reported By:Ben Matthews
Assigned To:
== 
Project:CMake
Issue ID:   15872
Category:   CMake
Reproducibility:always
Severity:   major
Priority:   normal
Status: new
== 
Date Submitted: 2015-12-06 21:39 MST
Last Modified:  2015-12-06 21:39 MST
== 
Summary:Programs with Fortran entry point (but calls into C)
don't link correctly using Intel or PGI compilers
Description: 
CMake always seems to link mixed language programs using the C++ compiler. Intel
and PGI link libcrt, which wants to have a main(). Programs with a Fortran entry
point typically won't have main(). Setting the linker_language property doesn't
seem to make a difference. 

Using the GNU compilers, CMake still uses the C++ compiler, but it gets the
libraries right and everything works as expected. 

Steps to Reproduce: 
git clone https://github.com/matthb2/cmake_f90_entry_bug.git
cd cmake_f90_entry_bug
mkdir build
cd build
CC=icc CXX=icpc FC=ifort cmake ../
make


make
Scanning dependencies of target testprog
[ 50%] Building Fortran object CMakeFiles/testprog.dir/test.f90.o
[100%] Linking CXX executable testprog
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crt1.o: In function
`_start':
(.text+0x20): undefined reference to `main'
CMakeFiles/testprog.dir/build.make:94: recipe for target 'testprog' failed
make[2]: *** [testprog] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testprog.dir/all' failed
make[1]: *** [CMakeFiles/testprog.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


Additional Information: 
Note that the example code is a bit of a simplified/contrived example. It will
work fine if you remove the HAS_CXX property, but real cases also incorporate
C/C++ modules and require that libc/libstdc++ be present. 

icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64,
Version 13.0.0.079 Build 20120731
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2015-12-06 21:39 Ben Matthews   New Issue
==

-- 

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