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

cnd*_*cnd 5 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")
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,我不希望(MSVS)将文件放入bin文件夹中的bin/Release或Debug文件夹中.我能以某种方式使用CMake实现它吗?

谢谢

And*_*dré 9

几个月前,我提出了一个类似的问题,我建议使用目标属性,并提到另一个答案.对于MSVC,您可以基于每个配置完全指定可执行文件,库,存档等的位置.

例如使用类似的东西:

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 )
Run Code Online (Sandbox Code Playgroud)

这将把你所有的库放在一个输出目录$ {youroutputdirectory}中,无论是在Debug还是Release配置中.