]> git.ipfire.org Git - thirdparty/xz.git/commit
CMake: Use -O2 instead of -O3 in CMAKE_BUILD_TYPE=Release.
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 17 Feb 2024 19:27:48 +0000 (21:27 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 19 Feb 2024 14:28:49 +0000 (16:28 +0200)
commit4430e075f7ccfc47972d6ca0aa1c3779fc265e10
tree0e9be5301abd86522a272f7f6a2ccec1f21320d9
parent025eb6d7879e4c4e8cb29716b371e0f4c1aea660
CMake: Use -O2 instead of -O3 in CMAKE_BUILD_TYPE=Release.

-O3 doesn't seem useful for speed but it makes the code bigger.
CMake makes is difficult for users to simply override the
optimization level: CFLAGS / CMAKE_C_FLAGS aren't helpful because
they go before CMAKE_C_FLAGS_RELEASE. Of course, users can override
CMAKE_C_FLAGS_RELEASE directly but then they have to remember to
add also -DNDEBUG to disable assertions.

This commit changes -O3 to -O2 in CMAKE_C_FLAGS_RELEASE if and only if
CMAKE_C_FLAGS_RELEASE cache variable doesn't already exist. So if
a custom value is passed on the command line (or reconfiguring an
already-configured build), the cache variable won't be modified.
CMakeLists.txt