# Compiling O2 without -O2

**URL:** <https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337>\
**Category:** O²\
**Created:** [September 2, 2019, 8:32am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337 "2019-09-02T08:32:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [September 2, 2019, 8:32am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/1 "2019-09-02T08:32:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![laphecet](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/laphecet/32/12_2.png) [@laphecet](https://alice-talk.web.cern.ch/u/laphecet)\
**Post date:** [September 2, 2019, 8:51am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/2 "2019-09-02T08:51:59Z")

</div>

How did you do it before the migration ?

---

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [September 2, 2019, 9:07am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/3 "2019-09-02T09:07:11Z")

</div>

I used to add this:

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

```

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![swenzel](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@swenzel](https://alice-talk.web.cern.ch/u/swenzel)\
**Post date:** [September 2, 2019, 9:17am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/4 "2019-09-02T09:17:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![laphecet](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/laphecet/32/12_2.png) [@laphecet](https://alice-talk.web.cern.ch/u/laphecet)\
**Post date:** [September 2, 2019, 9:27am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/5 "2019-09-02T09:27:34Z")

</div>

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 :

```auto
o2_add_library(Framework 
....
TARGETVARNAME targetName)

target_compile_options(${targetName} PUBLIC ... )

```

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

```auto
cmake -DCMAKE_BUILD_TYPE=Debug

```

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. [https://github.com/AliceO2Group/AliceO2/pull/2206](https://github.com/AliceO2Group/AliceO2/pull/2206) for a discussion : there are things to do there but which are not yet done (my bad).

---

<div class="post-metadata">

**Author:** ![eulisse](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/eulisse/32/19_2.png) [@eulisse](https://alice-talk.web.cern.ch/u/eulisse)\
**Post date:** [September 2, 2019, 9:45am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/6 "2019-09-02T09:45:28Z")

</div>

Even without the cmake, I think you can simply change CMAKE\_BUILD\_TYPE=Debug in your CMakeCache.txt

---

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [September 2, 2019, 10:02am UTC](https://alice-talk.web.cern.ch/t/compiling-o2-without-o2/337/7 "2019-09-02T10:02:20Z")

</div>

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