From cd1e4567f2b2373fa50afe1c0ebec84a684eb31e Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Sun, 25 Apr 2021 05:49:45 +0200 Subject: [PATCH] Add cmake option for -ftime-trace --- CMakeLists.txt | 1 + cmake/SfizzConfig.cmake | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b45737c0..d3954343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option_ex (SFIZZ_USE_SYSTEM_ABSEIL "Use Abseil libraries preinstalled on system" option_ex (SFIZZ_USE_SYSTEM_SIMDE "Use SIMDe libraries preinstalled on system" OFF) option_ex (SFIZZ_STATIC_DEPENDENCIES "Link dependencies statically" OFF) option_ex (SFIZZ_RELEASE_ASSERTS "Forced assertions in release builds" OFF) +option_ex (SFIZZ_PROFILE_BUILD "Profile the build time" OFF) # The fixed number of controller parameters set(SFIZZ_NUM_CCS 512) diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index 21d71585..40f248de 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -1,4 +1,5 @@ include(CMakeDependentOption) +include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(GNUWarnings) @@ -22,6 +23,18 @@ elseif((SFIZZ_LV2_UI OR SFIZZ_VST OR SFIZZ_AU OR SFIZZ_VST2) AND CMAKE_CXX_STAND set(CMAKE_CXX_STANDARD 14) endif() +# Set build profiling options +if(SFIZZ_PROFILE_BUILD) + check_c_compiler_flag("-ftime-trace" SFIZZ_HAVE_CFLAG_FTIME_TRACE) + check_cxx_compiler_flag("-ftime-trace" SFIZZ_HAVE_CXXFLAG_FTIME_TRACE) + if(SFIZZ_HAVE_CFLAG_FTIME_TRACE) + add_compile_options("$<$:-ftime-trace>") + endif() + if(SFIZZ_HAVE_CXXFLAG_FTIME_TRACE) + add_compile_options("$<$:-ftime-trace>") + endif() +endif() + # Process sources as UTF-8 if(MSVC) add_compile_options("/utf-8")