How do I use a target's path in add_custom_command in CMake?
In CMakeLists.txt have a library called "library.dll". I want to add a post build event to copy the resulting file to a different directory. The documentation says to use generator events, but it's not working:
add_custom_command(TARGET library.dll POST_BUILD COMMAND co开发者_如何转开发py $<TARGET_FILE:library.dll> \"${SOME_DIR}/bin\")
I'm using CMake 2.8.3 to generate VC++ 2010 project files on Windows 7.
Try the following changes:
Add the VERBATIM option which ensures that all arguments to the command will be escaped properly.
Instead of using the Windows built-in copy command, invoke CMake in command mode which has a platform independent copy command built-in.
The modified command looks like this:
add_custom_command(TARGET library.dll POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:library.dll> ${SOME_DIR}/bin VERBATIM)
精彩评论