2021-04-15 06:58:25 +00:00
cmake_minimum_required ( VERSION 3.10 )
2021-08-01 08:40:50 +00:00
2023-07-11 19:54:22 +00:00
# Run version helper script
include ( version.cmake )
set ( TRACY_VERSION_MAJOR ${ major } )
set ( TRACY_VERSION_MINOR ${ minor } )
set ( TRACY_VERSION_PATCH ${ patch } )
set ( TRACY_VERSION_STRING "${TRACY_VERSION_MAJOR}.${TRACY_VERSION_MINOR}.${TRACY_VERSION_PATCH}" )
project ( Tracy LANGUAGES CXX VERSION ${ TRACY_VERSION_STRING } )
2021-08-01 08:40:50 +00:00
2022-09-03 15:13:31 +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 } )
2022-08-31 16:06:51 +00:00
2021-08-01 08:40:50 +00:00
find_package ( Threads REQUIRED )
2022-08-04 11:51:08 +00:00
set ( TRACY_PUBLIC_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /public )
2022-08-31 16:06:51 +00:00
if ( TRACY_STATIC )
set ( TRACY_VISIBILITY "STATIC" )
else ( )
set ( TRACY_VISIBILITY "SHARED" )
endif ( )
add_library ( TracyClient ${ TRACY_VISIBILITY } "${TRACY_PUBLIC_DIR}/TracyClient.cpp" )
2021-08-01 08:40:50 +00:00
target_compile_features ( TracyClient PUBLIC cxx_std_11 )
2022-08-04 11:51:08 +00:00
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 } >
2021-12-06 16:58:25 +00:00
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e > )
2021-08-01 08:40:50 +00:00
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 }
)
2022-05-04 01:31:49 +00:00
# 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 ( )
2021-08-01 08:40:50 +00:00
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 )
2021-08-01 11:14:32 +00:00
macro ( set_option option help value )
option ( ${ option } ${ help } ${ value } )
if ( ${ option } )
message ( STATUS "${option}: ON" )
target_compile_definitions ( TracyClient PUBLIC ${ option } )
2021-08-01 08:40:50 +00:00
else ( )
2021-08-01 11:14:32 +00:00
message ( STATUS "${option}: OFF" )
2021-08-01 08:40:50 +00:00
endif ( )
endmacro ( )
2021-08-01 11:14:32 +00:00
set_option ( TRACY_ENABLE "Enable profiling" ON )
set_option ( TRACY_ON_DEMAND "On-demand profiling" OFF )
2023-11-26 11:51:05 +00:00
set_option ( TRACY_CALLSTACK "Enforce callstack collection for tracy regions" OFF )
2022-02-23 13:09:04 +00:00
set_option ( TRACY_NO_CALLSTACK "Disable all callstack related functionality" OFF )
2022-02-23 09:58:31 +00:00
set_option ( TRACY_NO_CALLSTACK_INLINES "Disables the inline functions in callstacks" OFF )
2021-08-01 11:14:32 +00:00
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 )
2022-02-23 13:16:50 +00:00
set_option ( TRACY_ONLY_IPV4 "Tracy will only accept connections on IPv4 addresses (disable IPv6)" OFF )
2021-08-01 11:14:32 +00:00
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 )
2021-12-18 19:14:06 +00:00
set_option ( TRACY_NO_SAMPLING "Disable call stack sampling" OFF )
2021-08-01 11:14:32 +00:00
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 )
2022-02-23 09:58:31 +00:00
set_option ( TRACY_NO_FRAME_IMAGE "Disable the frame image support and its thread" OFF )
2022-05-01 20:51:22 +00:00
set_option ( TRACY_NO_SYSTEM_TRACING "Disable systrace sampling" OFF )
2023-08-19 01:40:18 +00:00
set_option ( TRACY_PATCHABLE_NOPSLEDS "Enable nopsleds for efficient patching by system-level tools (e.g. rr)" OFF )
2022-02-23 09:58:31 +00:00
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 )
2022-05-10 13:49:59 +00:00
set_option ( TRACY_NO_CRASH_HANDLER "Disable crash handling" OFF )
2022-05-01 20:51:22 +00:00
set_option ( TRACY_TIMER_FALLBACK "Use lower resolution timers" OFF )
2023-11-10 22:17:39 +00:00
set_option ( TRACE_CLIENT_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" OFF )
2023-11-24 21:24:45 +00:00
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 )
2023-11-29 18:23:58 +00:00
set_option ( TRACY_ENABLE_IMAGE_CACHE "On glibc platforms, when doing offline symbol resolution, use an cache to determine the image path and offset instead of dladdr()" OFF )
2021-12-06 16:58:25 +00:00
2022-08-31 16:06:51 +00:00
if ( NOT TRACY_STATIC )
2021-12-06 16:58:25 +00:00
target_compile_definitions ( TracyClient PRIVATE TRACY_EXPORTS )
target_compile_definitions ( TracyClient PUBLIC TRACY_IMPORTS )
endif ( )
include ( CMakePackageConfigHelpers )
include ( GNUInstallDirs )
2023-07-11 19:54:22 +00:00
set_target_properties ( TracyClient PROPERTIES VERSION ${ PROJECT_VERSION } )
2022-08-04 11:51:08 +00:00
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 )
2021-12-06 16:58:25 +00:00
2022-01-12 22:57:41 +00:00
set ( client_includes
2022-08-04 11:51:08 +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 _ 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
$ { 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
2023-06-23 12:57:48 +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 C p u i d . h p p
2022-08-04 11:51:08 +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 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
2023-06-23 12:57:48 +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 S y s P o w e r . h p p
2022-08-04 11:51:08 +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 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 )
2022-01-12 22:57:41 +00:00
set ( common_includes
2022-08-04 11:51:08 +00:00
$ { 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 )
2022-01-12 22:57:41 +00:00
2021-12-06 16:58:25 +00:00
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 } )
2022-08-04 11:51:08 +00:00
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 )
2022-01-12 22:57:41 +00:00
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 )
2021-12-06 16:58:25 +00:00
install ( EXPORT TracyConfig
2022-05-04 01:31:49 +00:00
N A M E S P A C E T r a c y : :
2023-05-18 08:39:10 +00:00
F I L E T r a c y T a r g e t s . c m a k e
2023-07-11 19:54:22 +00:00
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 )
2023-05-18 08:39:10 +00:00
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 "
2023-07-11 19:54:22 +00:00
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 )
2023-05-18 08:39:10 +00:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /TracyConfig.cmake
2023-07-11 19:54:22 +00:00
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 )