Compiling O2 without -O2

how do I compile O2 (or at least the framework lib) without optimization flags after the migration to new CMake?

How did you do it before the migration ?

I used to add this:

target_compile_options(Framework PUBLIC -O0 -g -fno-omit-frame-pointer)

to the Framework/Core/CMakeLists.txt. Now I see the following error message:

CMake Error at Framework/Core/CMakeLists.txt:19 (target_compile_options):
  Cannot specify compile options for target "Framework" which is not built by
  this project.

Using O2Framework instead of Framework doesn’t work neither.

I think at some point before the migration it was really enough to say “cmake -DCMAKE_BUILD_TYPE=Debug” and I would expect it to be the same now.

OK, so you were using what I would call an invasive option (i.e. changing a CMakeLists.txt)

You can do almost as before as long as you know the actual name of the target. A robust way to get it is to use the TARGETVARNAME parameter of the o2_add_library function :


target_compile_options(${targetName} PUBLIC ... )

A less invasive (but more global) solution is indeed :


For completeness, note that further tweaking of (cxx) flags ought to be possible (by changing the env. or cache variables) with any cmake system, but that’s not currently 100% possible with our setup at the moment. See e.g. for a discussion : there are things to do there but which are not yet done (my bad).

Even without the cmake, I think you can simply change CMAKE_BUILD_TYPE=Debug in your CMakeCache.txt

Thank you all, I didn’t know I had been doing it the hard way.