News:

--

Main Menu

How to control CFLAGS in linux?

Started by hobbes1069, September 22, 2012, 01:43:19 PM

Previous topic - Next topic

hobbes1069

I've got a test package building of 2.6 but I need to fix a problem before I can start builds for Fedora/RPM Fusion.

I'm already using CMAKE_RELEASE_TYPE=RelWithDebInfo and cmake is honoring the required C/CXX flags that Fedora requires but it's still adding -O3 after the Fedora flags which contain (and require) -O2.

I know cmake already includes system specific build flags but I can't quite find where these are being generated. Any ideas?

Thanks,
Richard

mean

export CFLAGS=xxx does not work ?
Else
cmake -DCMAKE_C_FLAGS=xxxxx or similar should work

hobbes1069

Exporting works, I guess what I'm trying to say that the internal flags are overriding my flags, i.e. I'm specing -O2 but later in the list of options I'm seeing -O3. I assume the last flag wins?

Richard

mean


mean

Assuming you are building in release mode
adding
cmake -DCMAKE_C_FLAGS_RELEASE="-O2" -DCMAKE_CXX_FLAGS_RELEASE="-O2" xxxx
should do it

hobbes1069

I'll keep working on this... As much as I like cmake in general, this is one of the areas that can be very frustrating.

Trying "cmake --system-information" I get the following:
...
CMAKE_CXX_FLAGS == ""
CMAKE_CXX_FLAGS_DEBUG == "-g"
CMAKE_CXX_FLAGS_MINSIZEREL == "-Os -DNDEBUG"
CMAKE_CXX_FLAGS_RELEASE == "-O3 -DNDEBUG"
CMAKE_CXX_FLAGS_RELWITHDEBINFO == "-O2 -g"

CMAKE_C_FLAGS == ""
CMAKE_C_FLAGS_DEBUG == "-g"
CMAKE_C_FLAGS_MINSIZEREL == "-Os -DNDEBUG"
CMAKE_C_FLAGS_RELEASE == "-O3 -DNDEBUG"
CMAKE_C_FLAGS_RELWITHDEBINFO == "-O2 -g"
...

Which tells me that my "-DCMAKE_RELEASE_TYPE=RelWithDebInfo" should be doing the job... unless it's being overriden somewhere...

Thanks,
Richard

hobbes1069

Ok, getting closer. It looks like it's only ffmpeg that's building with -O3...

Richard

mean

from memory, one of the ffmpeg file does not like to be compiled with -O2
You'll run out of registers or something