如何不将Release或Debug添加到输出路径?

时间:2012-01-13 09:20:11

标签: cmake

以下是我当前的输出设置:

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实现它吗?

谢谢

2 个答案:

答案 0 :(得分:9)

几个月前我问过similar question,我建议使用target properties并提到another answer。对于MSVC,您可以按配置完全指定可执行文件,库,存档等的位置。

E.g。使用类似的东西:

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 config中。

答案 1 :(得分:0)

在 msvc 2015+ 中使用 cmake -G 'Ninja'

相关问题