I’m having trouble determining the right way to enforce `-O0` optimization
level when the user selects a boolean cache entry to  enable code coverage
with gcov. I tried something like:

if ( ENABLE_CODE_COVERAGE )
      set ( CMAKE_Fortran_FLAGS “${CMAKE_Fortran_FLAGS} -fprofile-arcs
-ftest-coverage -O0” )

but the issue is that the CMAKE_Fortran_FLAGS_<RELEASE|DEBUG|…> flags get
appended to the compiler flags so gfortran gets passed something like:

`gfortran -fprofile-arcs -ftest-coverage -O0 … -O3 …`

and since the `-O3` the right-most optimization option it takes precedent
over `-O0`.

What is the correct way to either ensure that `-O0` comes after `-O3` when
the user selects ENABLE_CODE_COVERAGE=TRUE or remove `-O3` entirely? Note
that CMAKE_Fortran_FLAGS_<…> are all (advanced) cache variables, and I
would like to let advanced users have the option to re-enable optimization
here should they so choose…
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to