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}")
I am not sure if these directories are intentional or a bug, but at the risk of forward incompatibility you could add:
if (MSVC_IDE)
# hack to get around the "Debug" and "Release" directories cmake tries to add on Windows
set_target_properties (${NAME} PROPERTIES PREFIX "../")
endif()
this has been working for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With