From aaf1304308d1494c96c31db17dde52bade3e6af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gr=C3=A9goire?= Date: Tue, 26 May 2026 08:11:47 +0200 Subject: [PATCH] Options.cmake: unify `set_options*` and `tracy_set_options` Renamed `tracy_*` versions to short version without prefix --- CMakeLists.txt | 66 ++++++++++++++++++++++----------------------- cmake/options.cmake | 54 +++++++++++++++++-------------------- 2 files changed, 57 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a5165bc..dc8c38bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,45 +108,45 @@ endif() include(cmake/options.cmake) -tracy_set_option(TRACY_ENABLE "Enable profiling" OFF TracyClient) -tracy_set_option(TRACY_ON_DEMAND "On-demand profiling" OFF TracyClient) -tracy_set_option_value(TRACY_CALLSTACK "Override the callstack collection depth for tracy zones" "" TracyClient) -tracy_set_option_value_as_string(TRACY_PLATFORM_HEADER "Path to a header providing TRACY_HAS_CUSTOM_* hooks for an unsupported platform" "" TracyClient) -tracy_set_option(TRACY_NO_CALLSTACK "Disable all callstack related functionality" OFF TracyClient) -tracy_set_option(TRACY_NO_CALLSTACK_INLINES "Disables the inline functions in callstacks" OFF TracyClient) -tracy_set_option(TRACY_ONLY_LOCALHOST "Only listen on the localhost interface" OFF TracyClient) -tracy_set_option(TRACY_NO_BROADCAST "Disable client discovery by broadcast to local network" OFF TracyClient) -tracy_set_option(TRACY_ONLY_IPV4 "Tracy will only accept connections on IPv4 addresses (disable IPv6)" OFF TracyClient) -tracy_set_option(TRACY_NO_CODE_TRANSFER "Disable collection of source code" OFF TracyClient) -tracy_set_option(TRACY_NO_CONTEXT_SWITCH "Disable capture of context switches" OFF TracyClient) -tracy_set_option(TRACY_NO_EXIT "Client executable does not exit until all profile data is sent to server" OFF TracyClient) -tracy_set_option(TRACY_NO_SAMPLING "Disable call stack sampling" OFF TracyClient) -tracy_set_option(TRACY_NO_VERIFY "Disable zone validation for C API" OFF TracyClient) -tracy_set_option(TRACY_NO_VSYNC_CAPTURE "Disable capture of hardware Vsync events" OFF TracyClient) -tracy_set_option(TRACY_NO_FRAME_IMAGE "Disable the frame image support and its thread" OFF TracyClient) -tracy_set_option(TRACY_NO_SYSTEM_TRACING "Disable systrace sampling" OFF TracyClient) -tracy_set_option(TRACY_PATCHABLE_NOPSLEDS "Enable nopsleds for efficient patching by system-level tools (e.g. rr)" OFF TracyClient) -tracy_set_option(TRACY_DELAYED_INIT "Enable delayed initialization of the library (init on first call)" OFF TracyClient) -tracy_set_option(TRACY_MANUAL_LIFETIME "Enable the manual lifetime management of the profile" OFF TracyClient) -tracy_set_option(TRACY_FIBERS "Enable fibers support" OFF TracyClient) -tracy_set_option(TRACY_NO_CRASH_HANDLER "Disable crash handling" OFF TracyClient) -tracy_set_option(TRACY_TIMER_FALLBACK "Use lower resolution timers" OFF TracyClient) -tracy_set_option(TRACY_DISALLOW_HW_TIMER "Disallow hardware timer (may be useful on VMs). Requires TRACY_TIMER_FALLBACK=ON" OFF TracyClient) -tracy_set_option(TRACY_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" OFF TracyClient) -tracy_set_option(TRACY_SYMBOL_OFFLINE_RESOLVE "Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution" OFF TracyClient) -tracy_set_option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation" OFF TracyClient) -tracy_set_option(TRACY_DEBUGINFOD "Enable debuginfod support" OFF TracyClient) -tracy_set_option(TRACY_IGNORE_MEMORY_FAULTS "Ignore instrumentation errors from memory free events that do not have a matching allocation" OFF TracyClient) +set_option(TRACY_ENABLE "Enable profiling" OFF TracyClient) +set_option(TRACY_ON_DEMAND "On-demand profiling" OFF TracyClient) +set_option_value(TRACY_CALLSTACK "Override the callstack collection depth for tracy zones" "" TracyClient) +set_option_value_as_string(TRACY_PLATFORM_HEADER "Path to a header providing TRACY_HAS_CUSTOM_* hooks for an unsupported platform" "" TracyClient) +set_option(TRACY_NO_CALLSTACK "Disable all callstack related functionality" OFF TracyClient) +set_option(TRACY_NO_CALLSTACK_INLINES "Disables the inline functions in callstacks" OFF TracyClient) +set_option(TRACY_ONLY_LOCALHOST "Only listen on the localhost interface" OFF TracyClient) +set_option(TRACY_NO_BROADCAST "Disable client discovery by broadcast to local network" OFF TracyClient) +set_option(TRACY_ONLY_IPV4 "Tracy will only accept connections on IPv4 addresses (disable IPv6)" OFF TracyClient) +set_option(TRACY_NO_CODE_TRANSFER "Disable collection of source code" OFF TracyClient) +set_option(TRACY_NO_CONTEXT_SWITCH "Disable capture of context switches" OFF TracyClient) +set_option(TRACY_NO_EXIT "Client executable does not exit until all profile data is sent to server" OFF TracyClient) +set_option(TRACY_NO_SAMPLING "Disable call stack sampling" OFF TracyClient) +set_option(TRACY_NO_VERIFY "Disable zone validation for C API" OFF TracyClient) +set_option(TRACY_NO_VSYNC_CAPTURE "Disable capture of hardware Vsync events" OFF TracyClient) +set_option(TRACY_NO_FRAME_IMAGE "Disable the frame image support and its thread" OFF TracyClient) +set_option(TRACY_NO_SYSTEM_TRACING "Disable systrace sampling" OFF TracyClient) +set_option(TRACY_PATCHABLE_NOPSLEDS "Enable nopsleds for efficient patching by system-level tools (e.g. rr)" OFF TracyClient) +set_option(TRACY_DELAYED_INIT "Enable delayed initialization of the library (init on first call)" OFF TracyClient) +set_option(TRACY_MANUAL_LIFETIME "Enable the manual lifetime management of the profile" OFF TracyClient) +set_option(TRACY_FIBERS "Enable fibers support" OFF TracyClient) +set_option(TRACY_NO_CRASH_HANDLER "Disable crash handling" OFF TracyClient) +set_option(TRACY_TIMER_FALLBACK "Use lower resolution timers" OFF TracyClient) +set_option(TRACY_DISALLOW_HW_TIMER "Disallow hardware timer (may be useful on VMs). Requires TRACY_TIMER_FALLBACK=ON" OFF TracyClient) +set_option(TRACY_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" OFF TracyClient) +set_option(TRACY_SYMBOL_OFFLINE_RESOLVE "Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution" OFF TracyClient) +set_option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation" OFF TracyClient) +set_option(TRACY_DEBUGINFOD "Enable debuginfod support" OFF TracyClient) +set_option(TRACY_IGNORE_MEMORY_FAULTS "Ignore instrumentation errors from memory free events that do not have a matching allocation" OFF TracyClient) # advanced -tracy_set_option(TRACY_VERBOSE "[advanced] Verbose output from the profiler" OFF TracyClient) +set_option(TRACY_VERBOSE "[advanced] Verbose output from the profiler" OFF TracyClient) mark_as_advanced(TRACY_VERBOSE) -tracy_set_option(TRACY_NO_INTERNAL_MESSAGE "[advanced] Prevent the profiler from logging messages" OFF TracyClient) +set_option(TRACY_NO_INTERNAL_MESSAGE "[advanced] Prevent the profiler from logging messages" OFF TracyClient) mark_as_advanced(TRACY_NO_INTERNAL_MESSAGE) -tracy_set_option(TRACY_DEMANGLE "[advanced] Don't use default demangling function - You'll need to provide your own" OFF TracyClient) +set_option(TRACY_DEMANGLE "[advanced] Don't use default demangling function - You'll need to provide your own" OFF TracyClient) mark_as_advanced(TRACY_DEMANGLE) if(rocprofiler-sdk_FOUND) - tracy_set_option(TRACY_ROCPROF_CALIBRATION "[advanced] Use continuous calibration of the Rocprof GPU time." OFF TracyClient) + set_option(TRACY_ROCPROF_CALIBRATION "[advanced] Use continuous calibration of the Rocprof GPU time." OFF TracyClient) mark_as_advanced(TRACY_ROCPROF_CALIBRATION) endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index f02174c3..de0a7b8a 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,54 +1,48 @@ -# Reusable option macros for CMake projects +# Reusable option macros for Tracy CMake projects # # Usage: -# set_option(OPTION_NAME "Help text" ON/OFF) - for boolean options -# set_option_value(VAR_NAME "Help text" "value") - for value options (CACHE STRING) +# set_option(OPTION_NAME "Help text" ON/OFF [TARGET]) - for boolean options +# set_option_value(VAR_NAME "Help text" "value" [TARGET]) - for value options (CACHE STRING) +# set_option_value_as_string(VAR_NAME "Help text" "value" [TARGET]) - for value options as C string literals # -# The tracy_set_option* variants optionally propagate the option as a PUBLIC -# compile definition on a target passed as trailing argument. Without a target -# they behave identically to the bare helpers above. +# [TARGET] is optional and specifies a target to which the option will +# be added as a compile definition (e.g., -DOPTION_NAME or -DVAR_NAME=value). -# Boolean options (ON/OFF) +# Boolean option (ON/OFF). macro(set_option option help value) option(${option} ${help} ${value}) if(${option}) message(STATUS "${option}: ON") + if(${ARGC} GREATER 3) + target_compile_definitions(${ARGV3} PUBLIC ${option}) + endif() else() message(STATUS "${option}: OFF") endif() endmacro() -# Value options (strings, numbers, etc.) +# Value option (string/number). macro(set_option_value var help default) set(${var} ${default} CACHE STRING "${help}") if(${var}) message(STATUS "${var}: ${${var}}") + if(${ARGC} GREATER 3) + target_compile_definitions(${ARGV3} PUBLIC ${var}=${${var}}) + endif() else() message(STATUS "${var}: (not set)") endif() endmacro() -# Boolean option, optionally propagated as PUBLIC compile definition. -macro(tracy_set_option option help value) - set_option(${option} "${help}" ${value}) - if(${option} AND ${ARGC} GREATER 3) - target_compile_definitions(${ARGV3} PUBLIC ${option}) - endif() -endmacro() - -# Value option, optionally propagated as PUBLIC compile definition (VAR=value). -macro(tracy_set_option_value var help default) - set_option_value(${var} "${help}" "${default}") - if(${var} AND ${ARGC} GREATER 3) - target_compile_definitions(${ARGV3} PUBLIC ${var}=${${var}}) - endif() -endmacro() - -# Value option propagated as a C string literal (VAR="value"). -# For options whose value is a path or string consumed verbatim in C/C++ code. -macro(tracy_set_option_value_as_string var help default) - set_option_value(${var} "${help}" "${default}") - if(${var} AND ${ARGC} GREATER 3) - target_compile_definitions(${ARGV3} PUBLIC "${var}=\"${${var}}\"") +# Value option embedded as a C string literal (VAR="value"). +macro(set_option_value_as_string var help default) + set(${var} ${default} CACHE STRING "${help}") + if(${var}) + message(STATUS "${var}: ${${var}}") + if(${ARGC} GREATER 3) + target_compile_definitions(${ARGV3} PUBLIC "${var}=\"${${var}}\"") + endif() + else() + message(STATUS "${var}: (not set)") endif() endmacro()