[CMake] Copying some files using CMake

Stormwind Dev stormwind.dev at googlemail.com
Thu Dec 23 11:18:43 EST 2010


Dear List,

I've got a question on copying some files from one directory to another 
using CMake.

Let's say, I got some libraries collected in a special directory. I want 
CMake to copy these libs to the distribution directory of my project. 
Using add_custom_command, I managed to have CMake copy my .exe to the 
distribution directory, but when I try to do this for my libraries 
something goes terribly wrong.

add_custom_command( TARGET MagicRPG POST_BUILD
         COMMAND copy \"$(TargetPath)\" .\\dist\\bin )

is what I did to copy my exe. When I use this

add_custom_command( TARGET MagicRPG POST_BUILD
         COMMAND copy \"$(TargetPath)\" 
\"${SDKS_BASE_DIR}/SDL/lib/SDL.dll\" .\\dist\\bin)

to get SDL.dll copied to dist/bin Visual Studio fails with message

Fehler    1    error MSB3073: Der Befehl "copy 
"D:\Projekte\cpp\games\Magic\bin\Debug\MagicRPG.exe" 
"D:/SDKs/SDL/lib/SDL.dll" .\dist\bin
if errorlevel 1 goto VCReportError
:VCEnd" wurde mit dem Code 1 beendet.    C:\Program Files 
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets    113    
6    MagicRPG

Can anybody please help me with the right syntax for copying multiple 
files at POST_BUILD?

Best

Michael



More information about the CMake mailing list