cmake RUNTIME_OUTPUT_DIRECTORY在Windows上 [英] cmake RUNTIME_OUTPUT_DIRECTORY on Windows
问题描述
我使用 cmake 来管理我的跨平台构建,我已经解决了除了这个问题的一切。我将 RUNTIME_OUTPUT_DIRECTORY
设置为存储数据文件的 bin /
目录。在Linux上,这工作正常。在Windows上,根据构建类型,可执行文件放置在 Debug
/ Release
子目录中。有没有什么办法让 cmake的复制的可执行程序以正确的目录,或(甚至更好)完全停止使用这些子目录?
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?
推荐答案
我一直在使用细前缀属性hack由 Ogapo 报告多年。它工作。
I've been using the fine prefix property hack reported by Ogapo for years. It works.
但是从CMake版本2.8,有正式支持,以避免在Windows上的Release / Debug子目录。
But as of CMake version 2.8, there is official support for avoiding the Release/Debug subdirectories on Windows.
使用无论是全球 CMAKE_< ARTIFACT> _OUTPUT_DIRECTORY_<结构>
变量,或按目标的< ARTIFACT> _OUTPUT_DIRECTORY_<结构>
属性,像这样:
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}")
这篇关于cmake RUNTIME_OUTPUT_DIRECTORY在Windows上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!