1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00
tracy/CMakeLists.txt
Lectem 6e619c094d Add new TRACY_ON_DEMAND_GPU_SYNC define
When using the tracy ON_DEMAND mode, it is ok in most cases to drop measurements and do a GPU clock synchronization (that may stall) during the first tracyCollect. This is not enabled by default in the CMakeLists for backward compatibility and because it may be a bit intrusive.
This commit also makes the OpenGL tracy TracyGpuZone* a tiny bit more efficient by not calling the threadlocal GetGpuCtx(). It is also more resilient if no context has been declared on this thread. This means that the application will not crash if a context was used on different threads even though declared only on one (thus GetGpuCtx().ptr == nullptr). Tracy does not support  this scenario, so on one hand this helps users by not crashing, on the other it is an error that is now silent.
2021-12-19 18:20:07 +01:00

78 lines
2.8 KiB
CMake

cmake_minimum_required(VERSION 3.10)
project(Tracy LANGUAGES CXX)
find_package(Threads REQUIRED)
add_library(TracyClient TracyClient.cpp)
target_compile_features(TracyClient PUBLIC cxx_std_11)
target_include_directories(TracyClient SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)
target_link_libraries(
TracyClient
PUBLIC
Threads::Threads
${CMAKE_DL_LIBS}
)
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)
set_option(TRACY_ON_DEMAND_GPU_SYNC "Synchronize with GPU on first TracyGpuCollect, drop any previous measurements (OpenGL only)" OFF)
set_option(TRACY_CALLSTACK "Collect call stacks" 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_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_FRAME_IMAGE "Disable capture of frame images" 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)
if(BUILD_SHARED_LIBS)
target_compile_definitions(TracyClient PRIVATE TRACY_EXPORTS)
target_compile_definitions(TracyClient PUBLIC TRACY_IMPORTS)
endif()
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(includes
${CMAKE_CURRENT_LIST_DIR}/TracyC.h
${CMAKE_CURRENT_LIST_DIR}/Tracy.hpp
${CMAKE_CURRENT_LIST_DIR}/TracyD3D11.hpp
${CMAKE_CURRENT_LIST_DIR}/TracyD3D12.hpp
${CMAKE_CURRENT_LIST_DIR}/TracyLua.hpp
${CMAKE_CURRENT_LIST_DIR}/TracyOpenCL.hpp
${CMAKE_CURRENT_LIST_DIR}/TracyOpenGL.hpp
${CMAKE_CURRENT_LIST_DIR}/TracyVulkan.hpp)
install(TARGETS TracyClient
EXPORT TracyConfig
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${includes}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT TracyConfig
FILE TracyConfig.cmake
DESTINATION share/Tracy)