I have a whole project and usually the project is build with release mode, but sometimes, I know certain lib have problem , I want to debug it and want to build this library to debug mode and other libs remain release mode, how can I do that?
Suppose the lib_foo
is that lib need to build with debug mode, I tried with target_compile_option
:
target_compile_option(lib_foo PRIVATE -O0 -g)
After add above line in the lib's cmake file and make with make VERBOSE=1
to build the lib_foo
library, I found following compile options in the terminal,
-O3 -DNDEBUG -O0 -g
the -O3 -DNDEBUG
flags is from the global release build compile flags, and the -O0 -g
is from target_compile_option
, so my lib_foo
is build with debug mode with -O0 -g
? But run a unittest which depends on lib_foo
, the performance of the unittest is not affect, I am not sure if above is right.
Is this the right way to build a certain lib with debug mode? or is there any better way to handle this?