summaryrefslogtreecommitdiff
path: root/indra/cmake/Tracy.cmake
blob: 9eee9eb57f6735e6f601d680d232c3708e70031a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- cmake -*-
include(Prebuilt)

include_guard()
add_library( ll::tracy INTERFACE IMPORTED )

# default Tracy profiling on for test builds, but off for all others
string(TOLOWER ${VIEWER_CHANNEL} channel_lower)
if(channel_lower MATCHES "^second life test")
  option(USE_TRACY "Use Tracy profiler." ON)
else()
    option(USE_TRACY "Use Tracy profiler." OFF)
endif()

if (LINUX)
  # tracy currently conflicts with llcommon/stdtypes.h on linux.  keep it disabled until we fix it
  set(USE_TRACY OFF)
endif(LINUX)

if (USE_TRACY)
  option(USE_TRACY_ON_DEMAND "Use on-demand Tracy profiling." ON)
  option(USE_TRACY_LOCAL_ONLY "Disallow remote Tracy profiling." OFF)

  use_system_binary(tracy)
  use_prebuilt_binary(tracy)

  target_include_directories( ll::tracy SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/tracy)

  target_compile_definitions(ll::tracy INTERFACE -DTRACY_ENABLE=1 -DTRACY_ONLY_IPV4=1)

  if (USE_TRACY_ON_DEMAND)
    target_compile_definitions(ll::tracy INTERFACE -DTRACY_ON_DEMAND=1)
  endif ()

  if (USE_TRACY_LOCAL_ONLY)
    target_compile_definitions(ll::tracy INTERFACE -DTRACY_NO_BROADCAST=1 -DTRACY_ONLY_LOCALHOST=1)
  endif ()

  # GHA runners don't always provide invariant TSC support, but always build with LL_TESTS enabled
  if (DARWIN AND LL_TESTS)
    target_compile_definitions(ll::tracy INTERFACE -DTRACY_TIMER_FALLBACK=1)
  endif ()

  # See: indra/llcommon/llprofiler.h
  add_compile_definitions(LL_PROFILER_CONFIGURATION=3)
endif (USE_TRACY)