cmake 同时 debug and relase

find_package   通过 FindXXX.cmake来查找包

release and debug:

http://stackoverflow.com/questions/2209929/linking-different-libraries-for-debug-and-release-builds-in-cmake-on-windows

According to the CMake documentation:

target_link_libraries(<target> [lib1 [lib2 [...]]] [[debug|optimized|general] <lib>] ...)

A "debug", "optimized", or "general" keyword indicates that the library immediately following it is to be used only for the corresponding build configuration.

So you should be able to do this:

add_executable( MyEXE ${SOURCES})

target_link_libraries( MyEXE debug 3PDebugLib)
target_link_libraries( MyEXE optimized 3PReleaseLib)
或者,一行内:
target_link_libraries(MyEXE debug 3PDebugLib optimized 3PReleaseLib)

或者像Qt中的作法:

SET(QT_${basename}_LIBRARY       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}

原文地址:https://www.cnblogs.com/justin_s/p/2336961.html