关于cmake:如何不将Release或Debug添加到输出路径?

How to not add Release or Debug to output path?

这是我当前的输出设置:

1
2
3
set( EXECUTABLE_OUTPUT_PATH"${CMAKE_CURRENT_SOURCE_DIR}/bin")
set( LIBRARY_OUTPUT_PATH"${CMAKE_CURRENT_SOURCE_DIR}/bin")
set( RUNTIME_OUTPUT_DIRECTORY"${CMAKE_CURRENT_SOURCE_DIR}/bin")

但是由于某些原因,我不想(MSVS)将文件放到bin文件夹中的bin / Release或Debug文件夹中。我可以通过CMake意识到吗?

谢谢


几个月前,有人问过类似的问题,我在其中建议使用目标属性,还提到了另一个答案。对于MSVC,您可以根据配置完全指定可执行文件,库,归档文件等的位置。

例如使用类似的东西:

1
2
3
4
5
6
if ( MSVC )
    set_target_properties( ${targetname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${youroutputdirectory} )
    set_target_properties( ${targetname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${youroutputdirectory} )
    set_target_properties( ${targetname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${youroutputdirectory} )
    # etc for the other available configuration types (MinSizeRel, RelWithDebInfo)
endif ( MSVC )

这会将所有库放在单个输出目录$ {youroutputdirectory}中,无论它是在Debug还是Release配置中。