2024-06-10 13:59:43 +00:00
cmake_minimum_required ( VERSION 3.10 )
# Run version helper script
2024-07-20 09:22:20 +00:00
include ( cmake/version.cmake )
2024-06-10 13:59:43 +00:00
project ( Tracy LANGUAGES CXX VERSION ${ TRACY_VERSION_STRING } )
2024-07-20 09:22:20 +00:00
file ( GENERATE OUTPUT .gitignore CONTENT "*" )
2024-06-10 13:59:43 +00:00
if ( ${ BUILD_SHARED_LIBS } )
set ( DEFAULT_STATIC OFF )
else ( )
set ( DEFAULT_STATIC ON )
endif ( )
option ( TRACY_STATIC "Whether to build Tracy as a static library" ${ DEFAULT_STATIC } )
find_package ( Threads REQUIRED )
set ( TRACY_PUBLIC_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /public )
if ( TRACY_STATIC )
set ( TRACY_VISIBILITY "STATIC" )
else ( )
set ( TRACY_VISIBILITY "SHARED" )
endif ( )
add_library ( TracyClient ${ TRACY_VISIBILITY } "${TRACY_PUBLIC_DIR}/TracyClient.cpp" )
target_compile_features ( TracyClient PUBLIC cxx_std_11 )
target_include_directories ( TracyClient SYSTEM PUBLIC
$ < B U I L D _ I N T E R F A C E : $ { T R A C Y _ P U B L I C _ D I R } >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e > )
target_link_libraries (
T r a c y C l i e n t
P U B L I C
T h r e a d s : : T h r e a d s
$ { C M A K E _ D L _ L I B S }
)
# Public dependency on some libraries required when using Mingw
if ( WIN32 AND ${ CMAKE_CXX_COMPILER_ID } MATCHES "GNU" )
target_link_libraries ( TracyClient PUBLIC ws2_32 dbghelp )
endif ( )
if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
find_library ( EXECINFO_LIBRARY NAMES execinfo REQUIRED )
target_link_libraries ( TracyClient PUBLIC ${ EXECINFO_LIBRARY } )
endif ( )
add_library ( Tracy::TracyClient ALIAS TracyClient )
macro ( set_option option help value )
option ( ${ option } ${ help } ${ value } )
if ( ${ option } )
message ( STATUS "${option}: ON" )
target_compile_definitions ( TracyClient PUBLIC ${ option } )
else ( )
message ( STATUS "${option}: OFF" )
endif ( )
endmacro ( )
set_option ( TRACY_ENABLE "Enable profiling" ON )
set_option ( TRACY_ON_DEMAND "On-demand profiling" OFF )
2024-07-20 09:22:20 +00:00
set_option ( TRACY_CALLSTACK "Enforce callstack collection for tracy regions" OFF )
2024-06-10 13:59:43 +00:00
set_option ( TRACY_NO_CALLSTACK "Disable all callstack related functionality" OFF )
set_option ( TRACY_NO_CALLSTACK_INLINES "Disables the inline functions in callstacks" OFF )
set_option ( TRACY_ONLY_LOCALHOST "Only listen on the localhost interface" OFF )
set_option ( TRACY_NO_BROADCAST "Disable client discovery by broadcast to local network" OFF )
set_option ( TRACY_ONLY_IPV4 "Tracy will only accept connections on IPv4 addresses (disable IPv6)" OFF )
set_option ( TRACY_NO_CODE_TRANSFER "Disable collection of source code" OFF )
set_option ( TRACY_NO_CONTEXT_SWITCH "Disable capture of context switches" OFF )
set_option ( TRACY_NO_EXIT "Client executable does not exit until all profile data is sent to server" OFF )
set_option ( TRACY_NO_SAMPLING "Disable call stack sampling" OFF )
set_option ( TRACY_NO_VERIFY "Disable zone validation for C API" OFF )
set_option ( TRACY_NO_VSYNC_CAPTURE "Disable capture of hardware Vsync events" OFF )
set_option ( TRACY_NO_FRAME_IMAGE "Disable the frame image support and its thread" OFF )
set_option ( TRACY_NO_SYSTEM_TRACING "Disable systrace sampling" OFF )
set_option ( TRACY_PATCHABLE_NOPSLEDS "Enable nopsleds for efficient patching by system-level tools (e.g. rr)" OFF )
set_option ( TRACY_DELAYED_INIT "Enable delayed initialization of the library (init on first call)" OFF )
set_option ( TRACY_MANUAL_LIFETIME "Enable the manual lifetime management of the profile" OFF )
set_option ( TRACY_FIBERS "Enable fibers support" OFF )
set_option ( TRACY_NO_CRASH_HANDLER "Disable crash handling" OFF )
set_option ( TRACY_TIMER_FALLBACK "Use lower resolution timers" OFF )
2024-07-20 09:22:20 +00:00
set_option ( TRACY_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" OFF )
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 )
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 )
# advanced
set_option ( TRACY_DEMANGLE "[advanced] Don't use default demangling function - You'll need to provide your own" OFF )
mark_as_advanced ( TRACY_DEMANGLE )
2024-06-10 13:59:43 +00:00
if ( NOT TRACY_STATIC )
target_compile_definitions ( TracyClient PRIVATE TRACY_EXPORTS )
target_compile_definitions ( TracyClient PUBLIC TRACY_IMPORTS )
endif ( )
include ( CMakePackageConfigHelpers )
include ( GNUInstallDirs )
set_target_properties ( TracyClient PROPERTIES VERSION ${ PROJECT_VERSION } )
set ( tracy_includes
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y C . h
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y . h p p
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y D 3 D 1 1 . h p p
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y D 3 D 1 2 . h p p
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y L u a . h p p
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y O p e n C L . h p p
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y O p e n G L . h p p
$ { T R A C Y _ P U B L I C _ D I R } / t r a c y / T r a c y V u l k a n . h p p )
set ( client_includes
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / t r a c y _ c o n c u r r e n t q u e u e . h
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / t r a c y _ r p m a l l o c . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / t r a c y _ S P S C Q u e u e . h
2024-07-20 09:22:20 +00:00
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y K C o r e . h p p
2024-06-10 13:59:43 +00:00
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y A r m C p u T a b l e . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y C a l l s t a c k . h
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y C a l l s t a c k . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y C p u i d . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y D e b u g . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y D x t 1 . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y F a s t V e c t o r . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y L o c k . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y P r o f i l e r . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y R i n g B u f f e r . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y S c o p e d . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y S t r i n g H e l p e r s . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y S y s P o w e r . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y S y s T i m e . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y S y s T r a c e . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c l i e n t / T r a c y T h r e a d . h p p )
set ( common_includes
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / t r a c y _ l z 4 . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / t r a c y _ l z 4 h c . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y A l i g n . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y A l l o c . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y A p i . h
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y C o l o r . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y F o r c e I n l i n e . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y M u t e x . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y P r o t o c o l . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y Q u e u e . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y S o c k e t . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y S t a c k F r a m e s . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y S y s t e m . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y U w p . h p p
$ { T R A C Y _ P U B L I C _ D I R } / c o m m o n / T r a c y Y i e l d . h p p )
install ( TARGETS TracyClient
E X P O R T T r a c y C o n f i g
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
L I B R A R Y D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
A R C H I V E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } )
install ( FILES ${ tracy_includes }
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } / t r a c y )
install ( FILES ${ client_includes }
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } / c l i e n t )
install ( FILES ${ common_includes }
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } / c o m m o n )
install ( EXPORT TracyConfig
N A M E S P A C E T r a c y : :
F I L E T r a c y T a r g e t s . c m a k e
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A R O O T D I R } / T r a c y )
include ( CMakePackageConfigHelpers )
configure_package_config_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /Config.cmake.in
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / T r a c y C o n f i g . c m a k e "
I N S T A L L _ D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A R O O T D I R } / T r a c y )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /TracyConfig.cmake
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A R O O T D I R } / T r a c y )
2024-07-20 09:22:20 +00:00
option ( TRACY_CLIENT_PYTHON "Whether to build Tracy python client library" OFF )
if ( TRACY_CLIENT_PYTHON )
if ( TRACY_STATIC )
message ( FATAL_ERROR "Python-bindings require a shared client library" )
endif ( )
add_subdirectory ( python )
endif ( )