We use CMake for generating the Visual Studio files of our sources in our SVN. Now my tool requires some DLL files to be in the same folder as the executable. The DLL files are in a folder alongside the source.
How can I change my CMakeLists.txt such that the generated Visual Studio project will either have already the particular DLL files in the release/debug folders or will copy them upon compilation?
I’d use
add_custom_commandto achieve this along withcmake -E copy_if_different.... For full info runSo in your case, if you have the following directory structure:
and your CMake target to which the command applies is
MyTest, then you could add the following to your CMakeLists.txt:If you just want the entire contents of the
/libs/directory copied, usecmake -E copy_directory:If you need to copy different dlls depending upon the configuration (Release, Debug, eg) then you could have these in subdirectories named with the corresponding configuration:
/libs/Release, and/libs/Debug. You then need to inject the configuration type into the path to the dll in theadd_custom_commandcall, like this: