CMake CXXFlags -O2 / -O3

1.3k Views Asked by At

I'm not really familiar with CMake at all but I got the task to clean-up the CXXFlags that are used (-O2 and -O3).

The Log prints out: "USING CXXFLAGS = '-g -O2 -fdebug-prefix-map=/build/cgal-ZyilPF/cgal-4.11=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -frounding-math -O3 -DNDEBUG'"

I've found out that -O2 and -O3 are for optimization, but I wonder how it is possible that both are used?

1

There are 1 best solutions below

0
Hanjoung Lee On

In GCC manual, it says:

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

So if you use GCC, -O3 works in your case. I'm not sure about other compilers.