Thanks a lot for all these informations. I wrote a macro to be sure to replace all the -O3 flags ...
# replace_ccxx_flag: replace compilation flags from the compiler command line # flag_orig: the flag to be replace # flag_dest: the new flag value macro(replace_ccxx_flag flag_orig flag_dest) string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE "${flag_orig}" "${flag_dest}" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") endmacro() Best regards, YC ----- Mail original ----- De: "Chuck Atkins" <chuck.atk...@kitware.com> À: "ycollette nospam" <ycollette.nos...@free.fr> Cc: "Dan Liew" <d...@su-root.co.uk>, "cmake" <cmake@cmake.org> Envoyé: Jeudi 16 Février 2017 16:07:21 Objet: Re: [CMake] Default CMAKE_C_FLAGS value by OS Hi YC, cmake version on fedora 25: 3.6.2 Fedora is specifically patching CMake in the RPM spec file to reduce the gcc flag from O3 to O2 so it's the distributuion's packaging making that change, not CMake itself. If you download and build the source from cmake.org then you'll get O3 as default for gcc release builds. That being said, I do think we should revisit the use of O3 by default given the safety issues surounding it. - Chuck -- 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