libdeflate icon indicating copy to clipboard operation
libdeflate copied to clipboard

Do not unconditionally set `CMAKE_C_FLAGS_RELEASE`

Open danfe opened this issue 1 year ago • 2 comments

Most GNU/Linux and *BSD distributions build their packages with certain default compilation flags, e.g. on FreeBSD, our framework sets -DCMAKE_C_FLAGS_RELEASE:STRING="${CFLAGS} -DNDEBUG" and CFLAGS already includes -O2 plus some other useful options, or it could be set by the user to her liking which we should respect. May I suggest the following small patch to CMakeLists.txt:

 # Set common C compiler flags for all targets (the library and the programs).
-set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+if(NOT CMAKE_C_FLAGS_RELEASE)
+    set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+endif()
 set(CMAKE_C_STANDARD 99)

danfe avatar Jan 09 '25 16:01 danfe

set by the user to her liking

Two wrongs don't make a right.

Clownacy avatar Feb 11 '25 18:02 Clownacy

I was hoping to see this addressed somehow in the latest 1.25 release, but alas. Anything in particular you don't like about the suggested patch, Eric?

danfe avatar Nov 24 '25 15:11 danfe