MantisBT - CMake
View Issue Details
0015561CMakeCMakepublic2015-05-08 09:002015-11-02 09:15
Wojciech Mamrak 
 
highminoralways
closedno change required 
PCWindows7.1
CMake 3.2.2 
 
0015561: file COPY FILES_MATCHING PATTERN copies folders' structure
This command:

file(COPY "src/" DESTINATION "dst" FILES_MATCHING PATTERN "*.bat")

copies not only all *.bat files from src to dst, but also folders' structure.
For example, if src is:
src:
 - foo.bat
 - bar.bat
 - images [folder]
   - foo.png
   - bar [folder]

then after calling the command, dst is:
dst:
 - foo.bat
 - bar.bat
 - images [folder]
   - bar [folder]
No tags attached.
Issue History
2015-05-08 09:00Wojciech MamrakNew Issue
2015-05-08 09:02Wojciech MamrakNote Added: 0038731
2015-05-08 09:33Brad KingNote Added: 0038732
2015-05-08 09:33Brad KingStatusnew => resolved
2015-05-08 09:33Brad KingResolutionopen => no change required
2015-05-08 10:26Wojciech MamrakNote Added: 0038736
2015-11-02 09:15Robert MaynardNote Added: 0039806
2015-11-02 09:15Robert MaynardStatusresolved => closed

Notes
(0038731)
Wojciech Mamrak   
2015-05-08 09:02   
Forgot to mention, that file extension is irrelevant.
(0038732)
Brad King   
2015-05-08 09:33   
This is expected. Your "src/" source says to copy the directory, and copying directories preserves their structure. The FILES_MATCHING option just filters the set of files within that structure.

I've updated the documentation:

 Help: Clarify file(COPY) directory semantics
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f39d26ca [^]

You can use file(GLOB_RECURSE) to collect files from a directory structure and then specify the results as the list of files to file(COPY).
(0038736)
Wojciech Mamrak   
2015-05-08 10:26   
I expected this is not a bug but a feature, but the documentation did not make it clear. Now it is OK.
Yes, this is how I solved this.

regards
(0039806)
Robert Maynard   
2015-11-02 09:15   
Closing resolved issues that have not been updated in more than 4 months.