I'm using cmake for managing my cross-platform builds, and I have everything worked out except for this problem. I set RUNTIME_OUTPUT_DIRECTORY
to a bin/
directory where I have data files stored. On Linux, this works fine. On Windows, the executables get placed in the Debug
/Release
sub-directory depending on the build type. Is there any way to get cmake to copy the executable to the proper directory, or (even better) stop using these sub-directories altogether?
I've been using the fine prefix property hack reported by Ogapo for years. It works.
But as of CMake version 2.8, there is official support for avoiding the Release/Debug subdirectories on Windows.
Use either the global CMAKE_<ARTIFACT>_OUTPUT_DIRECTORY_<CONFIGURATION>
variables, or the per-target <ARTIFACT>_OUTPUT_DIRECTORY_<CONFIGURATION>
properties, like so:
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")