[CMake] Default CMAKE_C_FLAGS value by OS
ycollette.nospam at free.fr
ycollette.nospam at free.fr
Thu Feb 16 10:56:00 EST 2017
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.atkins at kitware.com>
À: "ycollette nospam" <ycollette.nospam at free.fr>
Cc: "Dan Liew" <dan at su-root.co.uk>, "cmake" <cmake at 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
More information about the CMake
mailing list