[Libwebsockets] Patch: -O3 set in CMakeLists.txt even when compiling for debug

Bruce Perens bruce at perens.com
Thu Jun 11 02:46:12 CEST 2015


When building with "cmake -DCMAKE_BUILD_TYPE:STRING=Debug", -O3 is still
set. This makes it difficult to debug, since GDB shows some function
arguments as "optimized out". You actually shouldn't set "-O3" in
CMakeFiles.txt, since cmake already provides this definition:

// Flags used by the compiler during release builds.
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG

And arguably, you might want to set CMAKE_C_FLAGS_RELEASE and
CMAKE_C_FLAGS_DEBUG instead of CMAKE_C_FLAGS.

Patch below.

   Thanks

   Bruce

--- libwebsockets-old/CMakeLists.txt    2015-06-10 12:03:56.520870113 -0700
+++ libwebsockets/CMakeLists.txt        2015-06-10 17:34:41.936692691 -0700
@@ -402,9 +402,9 @@
                 set(VISIBILITY_FLAG -fvisibility=hidden)
     endif()
     if (UNIX)
-               set(CMAKE_C_FLAGS "-Wall -Werror -O3 ${VISIBILITY_FLAG}
${CMAKE_C_FLAGS}" )
+               set(CMAKE_C_FLAGS "-Wall -Werror ${VISIBILITY_FLAG}
${CMAKE_C_FLAGS}" )
     else(UNIX)
-               set(CMAKE_C_FLAGS "-Wall -O3 ${VISIBILITY_FLAG}
${CMAKE_C_FLAGS}" )
+               set(CMAKE_C_FLAGS "-Wall ${VISIBILITY_FLAG}
${CMAKE_C_FLAGS}" )
     endif(UNIX)
 endif ()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20150610/c4e48fbb/attachment.html>


More information about the Libwebsockets mailing list