CMake Visual Studio“调试”文件夹

发布于 2024-12-01 16:06:42 字数 83 浏览 0 评论 0原文

Visual Studio 坚持要求在使用 CMake 时必须在 bin/Debug/ 而不仅仅是 bin/ 中创建可执行文件。 有办法解决这个问题吗?

Visual Studio insists that it has to create executables in bin/Debug/ instead of just bin/, when using CMake.
Is there a way to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁梦 2024-12-08 16:06:42

是的,但不是很漂亮...

您需要更新 RUNTIME_OUTPUT_DIRECTORYLIBRARY_OUTPUT_DIRECTORYARCHIVE_OUTPUT_DIRECTORY ALL

最简单的方法是使用其 CMAKE_... 等效项“全局”执行此操作。例如,检查以下示例,将 bin/ 和 lib/ 设置为“全局”二进制/库输出目录:

# First for the generic no-config case (e.g. with mingw)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
    string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
    set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin )
    set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
    set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

或者,您可以尝试运行所有可用目标并随后修改其属性...

请注意,这不会设置.pdb 文件的位置。我仍然没有找到一种令人满意的方法将所有相关的 .pdb 文件放入 bin/ 目录中。

Yes, but is not really pretty...

You will need to update the RUNTIME_OUTPUT_DIRECTORY, LIBRARY_OUTPUT_DIRECTORY and ARCHIVE_OUTPUT_DIRECTORY properties on ALL your targets. And you will need to do this for every configuration (Debug, RelWithDebInfo, etc.)

The easiest way is to do this "globally" with their CMAKE_... equivalents. E.g. check the following sample which sets bin/ and lib/ as the "global" binary/library output-directories:

# First for the generic no-config case (e.g. with mingw)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
    string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
    set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin )
    set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
    set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

Alternatively, you can try to run through all the available targets and modify its properties afterwards...

Note that this does not set the location of your .pdb files. I still have not found a satisfying way to put all the relevant .pdb files in the bin/ directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文