Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add _ITERATOR_DEBUG_LEVEL to CMake?

I am new to CMake, and I want to set _ITERATOR_DEBUG_LEVEL to 0 for Release build, and 2 for Debug build, to fix issues when trying to compile a project that depends on other projects.

Error:

_iterator_debug_level value '2' doesn't match value '0' (this is for Release Win32 build, where the main project has the value disabled(0) and the project that it is dependent on has it enabled for some reason, somewhere)

I do not have a C/C++ properties section in the main project since it is a Utility project that depends heavily on CMake. Hence I need to fix this through CMake options only.

Can anyone point me to the way of setting visual studio option via CMake?

like image 986
Swtsvn Avatar asked Sep 11 '25 21:09

Swtsvn


1 Answers

add_definitions is deprecated. Use add_compile_definitions to specify the iterator debug level in CMakeLists.txt.

add_compile_definitions($<$<CONFIG:Debug>:_ITERATOR_DEBUG_LEVEL=1>)
like image 95
hungptit Avatar answered Sep 13 '25 11:09

hungptit