diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bb4adc4aa8..3d1da80c98c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,7 @@ option(WANT_DEBUG_ASAN "Enable AddressSanitizer" OFF) option(WANT_DEBUG_TSAN "Enable ThreadSanitizer" OFF) option(WANT_DEBUG_MSAN "Enable MemorySanitizer" OFF) option(WANT_DEBUG_UBSAN "Enable UndefinedBehaviorSanitizer" OFF) +option(WANT_DEBUG_GPROF "Enable gprof profiler" OFF) OPTION(BUNDLE_QT_TRANSLATIONS "Install Qt translation files for LMMS" OFF) @@ -664,6 +665,22 @@ elseif(MSVC) add_compile_options("/utf-8") ENDIF() +# gcc builds support gprof for profiling +# clang too seems to support gprof, but i couldn't get it working. +# if needed, change the if condition to "GNU|CLANG" +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set(STATUS_GPROF ", NOT SUPPORTED BY THIS COMPILER") + set(WANT_DEBUG_GPROF OFF) +endif() + +if(WANT_DEBUG_GPROF) + add_compile_options(-pg) + add_link_options(-pg) + set(STATUS_GPROF "OK") +else() + set(STATUS_GPROF "DISABLED ${STATUS_GPROF}") +endif() + # add enabled sanitizers function(add_sanitizer sanitizer supported_compilers want_flag status_flag) if(${want_flag}) @@ -831,6 +848,7 @@ MESSAGE( "* Debug using ThreadSanitizer : ${STATUS_DEBUG_TSAN}\n" "* Debug using MemorySanitizer : ${STATUS_DEBUG_MSAN}\n" "* Debug using UBSanitizer : ${STATUS_DEBUG_UBSAN}\n" +"* Profile using GNU profiler : ${STATUS_GPROF}\n" ) MESSAGE( diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 203c3168f77..27796cc9dd7 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF() # Additional compile flags if(NOT MSVC) set(COMPILE_FLAGS ${COMPILE_FLAGS} -O3 -c - -fomit-frame-pointer -funroll-loops -ffast-math -fno-strict-aliasing + -funroll-loops -ffast-math -fno-strict-aliasing ${PIC_FLAGS} ) endif() diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index 84c4694655f..93b54ae47ff 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -6,7 +6,7 @@ LIST(SORT PLUGIN_SOURCES) if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast") else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fno-strict-aliasing -funroll-loops -ffast-math") endif() FOREACH(_item ${PLUGIN_SOURCES}) GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE)