MantisBT - CMake
View Issue Details
0010733CMakeCMakepublic2010-05-19 09:312010-08-31 18:01
Rolf Eike Beer 
David Cole 
normalfeatureN/A
closedno change required 
CMake-2-8 
CMake 2.8.3 
0010733: Allow copying files from Windows shares
I have some stuff on a Windows share (in fact a Samba server, but that surely doesn't matter) that I need at some point in the build. Currently the code looks like that:

ADD_CUSTOM_TARGET(target
    COMMAND xcopy /Y /C /S /I "\\\\server\\directory" "directory"
        ...)

Obviously that only works on Windows. I would like to be able to copy stuff from that server in a useful way, e.g. using FILE(COPY ...) or FILE(DOWNLOAD ...).
No tags attached.
Issue History
2010-05-19 09:31Rolf Eike BeerNew Issue
2010-05-24 12:11Clinton StimpsonNote Added: 0020816
2010-08-18 00:45David ColeNote Added: 0021792
2010-08-18 01:16Rolf Eike BeerNote Added: 0021794
2010-08-18 09:53Clinton StimpsonNote Added: 0021803
2010-08-18 19:01Clinton StimpsonNote Added: 0021811
2010-08-21 14:20David ColeNote Added: 0021874
2010-08-21 14:20David ColeStatusnew => assigned
2010-08-21 14:20David ColeAssigned To => David Cole
2010-08-21 15:57Rolf Eike BeerNote Added: 0021875
2010-08-23 23:19David ColeNote Added: 0021909
2010-08-23 23:20David ColeNote Added: 0021910
2010-08-23 23:20David ColeStatusassigned => closed
2010-08-23 23:20David ColeResolutionopen => no change required
2010-08-31 18:01David ColeTarget Version => CMake 2.8.3

Notes
(0020816)
Clinton Stimpson   
2010-05-24 12:11   
Could probably move some code from Paraview into kwsys?
(0021792)
David Cole   
2010-08-18 00:45   
Clinton, what code in ParaView are you referring to?

Rolf, would you expect file(COPY to work with "//server/directory"? (With forward slashes, on all platforms?)
(0021794)
Rolf Eike Beer   
2010-08-18 01:16   
That would be the most obvious solution I can think of.
(0021803)
Clinton Stimpson   
2010-08-18 09:53   
Actually you can probably do without some of the code in paraview. It was for browsing servers and shares. In this case, the //server/share/directory part is already known and the normal Win32 methods for files should work.

kwsys was patched yesterday with a fix for unc paths. I'm curious if that fixed this problem too.
(0021811)
Clinton Stimpson   
2010-08-18 19:01   
Oh, I see this is asking for cmake to know the windows share protocol on all platforms. The code in ParaView I was referring to is Windows specific.

I guess the user could make their own macro that does either xcopy or smbget depending on the platform, or use a cross platform protocol instead.
(0021874)
David Cole   
2010-08-21 14:20   
I have some code that runs every night that uses the following chunk of script to copy files:
      EXECUTE_PROCESS(
        COMMAND ${CMAKE_EXECUTABLE_NAME} -E copy
          "${reldir}/${f}"
          "${ED_upload_destination}/${ED_site}/${f}"
        )

In my case, on windows, I am setting ED_upload_destination with a UNC path like "//server/share/dir" and it works just fine.

I do not do the same thing from Linux boxes. On Linux, I use mount to map a samba mount point to "//server/share/dir" at the path "/mnt/server".

I'm not sure if file(COPY will already handle "//server/share/dir" references on Windows or not, but I will test it out. (I think it works already.)

I think it's beyond the scope of CMake for you to expect that we'll auto-mount network drives on Mac and Linux so that you can reference them with UNC paths. I think it's a machine specific thing that involves possible permissions and credentials as well. I don't see how we'd support it unless somebody knows of a magic library (open source, BSD-ish license) that we can include in CMake to give us this functionality.

I'm inclined (after my investigation proves me right or wrong) to say CMake is good enough as it is, w.r.t. file copying, and that making things appear uniformly from a set of machines is up to the end user.

Use "file(COPY" or "cmake -E copy" : on Windows, UNC paths work fine, on other OSes, mount the UNC path using the native OS mounting utilities first, and then use the appropriate path.

If you agree, please respond here and I'll resolve this as "Won't Fix".

Thanks,
David
(0021875)
Rolf Eike Beer   
2010-08-21 15:57   
I will test this and report back.
(0021909)
David Cole   
2010-08-23 23:19   
All three of these techniques work for me on Windows with cmake 2.8.2:

file(
  COPY "C:/Users/davidcole/Desktop/junk.txt"
  DESTINATION "//server/share/dir"
  )
# with file(COPY the source file's time stamps are preserved
# destination file name is the same

configure_file(
  "C:/Users/davidcole/Desktop/junk.txt"
  "//server/share/dir/junk2.txt"
  COPYONLY
  )
# configure_file writes a new file
# dst name may easily be different

execute_process(COMMAND ${CMAKE_COMMAND} -E copy
  "C:/Users/davidcole/Desktop/junk.txt"
  "//server/share/dir/junk3.txt"
  )
# -E copy also writes a new file
# dst name may easily be different
(0021910)
David Cole   
2010-08-23 23:20   
Based on the information in the notes, I'm closing this issue. Please re-open if you feel there is more to discuss about it.