cmake msvc debug&release different libs link

cmake msvc debug&release different libs link

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:

Cmake的项目生成器总的来说可以分为两种:

  1. single configuration 包括Unix Makefile , NMake Makefile, MinGw Makefile
  2. multi configuration 包括Visual StudioXcode, 看上去带IDE的都属于这个类别

cmakelist怎么写:

#     message("Debug")
    # set (CV_LIB_DIR ${CV_DIR}/bin/opencv_world450d.dll)
    set (CV_LIBD_DIR ${CV_DIR}/lib/opencv_world450d.lib)

# ELSE()
    # message("Release")
    # set (CV_LIB_DIR ${CV_DIR}/bin/opencv_world450.dll)
    set (CV_LIB_DIR ${CV_DIR}/lib/opencv_world450.lib)
    # message( ${CV_LIB_DIR})
# ENDIF()

#eigen3
set (eigen3_dir ${3RD_DIR}/eigen-3.3.9)
# add_subdirectory(${eigen3_dir})
include_directories (${eigen3_dir})

# add_executable(Rasterizer main.cpp rasterizer.hpp rasterizer.cpp Triangle.hpp Triangle.cpp)
target_link_libraries(Rasterizer
    debug ${CV_LIBD_DIR}
    optimized ${CV_LIB_DIR})

链接库的时候进行标志的设置

debug 对应debug

optimized 对应 release

general 对应通用的

© 2021 hanbaoaaa record.浙ICP备20005263号
asdad
联系方式 asdasd
2021-5-8 4:19
sss
回复数 (0) 点击展开
加载更多

新增评论

称呼
联系方式
邮箱(选填)
内容

提交

取消