CMake RelWithDebInfo links to Debug libs

前端 未结 3 1075
旧巷少年郎
旧巷少年郎 2021-02-04 10:04

I have a project which links to half a dozen libraries, among them OpenCV.
Since Release variant is crashing, while Debug is working fine (just a lot slower), I wanted to co

3条回答
  •  臣服心动
    2021-02-04 10:41

    you could disable level 2 optimizations with the default cmake release build using the below snippet. This would still pick release opencvworld (build with full optimizations) from the un-optimized (yet Release) app code. Using this we can step through the app's code line-by-line with full variable visibility.. as good as the debug build minus the need to link with debug opencv or mixing the CRTs or doing a full debug build of all components involved.

    if (WIN32)
    
      SET (CMAKE_CXX_FLAGS_RELEASE "/Zi /Od")
    
      SET_TARGET_PROPERTIES(
       xyz PROPERTIES 
       LINK_FLAGS 
       "/DEBUG /OPT:REF /OPT:ICF"
      )
    
    endif (WIN32)
    

提交回复
热议问题