0

I usually have a .sln file, but in this case I use a CMakeLists.txt, opened from visual studio

I just cannot find in google how to disable the compiler optimizations to be able:

  • to see variable contents with watches
  • get into lambda functions

enter image description here

enter image description here

sujoybyte
  • 584
  • 4
  • 19
  • 1
    If you use CMake, use `cmake -DCMAKE_BUILD_TYPE=Debug` to create a debug project. This should not have any optimizations. – Some programmer dude May 04 '23 at 09:19
  • 4
    CMake for Visual studio should respect the Debug and Release flavors; you can select either in the IDE – Botje May 04 '23 at 09:19
  • @Someprogrammerdude that's for single-config generators. the CMake Visual Studio generator is a multi-config generator. see also https://stackoverflow.com/a/74077157/11107541. Botje's on the mark I think. – starball May 04 '23 at 09:44
  • as I select the debug config , it complains about debug levels (error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2') – pf12345678910 May 04 '23 at 10:15
  • 4
    Sounds like you're linking to a non-debug library, all code in your project needs to be using the same visual studio runtime – Alan Birtles May 04 '23 at 10:16
  • it uses a build of llvm, hence my question, I was wondering how to build it for debugging (cmake.exe -H. -G Ninja -DCMAKE_C_COMPILER:PATH="%ClangClExe%" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF -DCMAKE_CXX_COMPILER:PATH="%ClangClExe%" -DCMAKE_LINKER="%ClangLinkExe%" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" --build ../llvm-source/llvm BuildConsole /command="cmake.exe --build .") – pf12345678910 May 04 '23 at 11:00
  • I'll try -DCMAKE_BUILD_TYPE=Debug – pf12345678910 May 04 '23 at 11:08

0 Answers0