Skip to content

Commit

Permalink
[CMake] Added the RAZ_USE_PROFILING CMake option
Browse files Browse the repository at this point in the history
- This enables the use of Tracy for profiling purposes
  • Loading branch information
Razakhel committed Mar 9, 2024
1 parent 22f88f0 commit 5ce72c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,17 @@ else ()
message(STATUS "[RaZ] Lua scripting DISABLED")
endif ()

# The target is always linked, as the include files & their macros should be unconditionally available for ease of use; Tracy macros do something only
# if the expected definition is available, which only is if the related CMake option is set
# It also always compiles the implementation file, but making it conditional would be much more of a hassle. This may change in the future
target_link_libraries(RaZ PUBLIC Tracy)

if (RAZ_USE_PROFILING)
message(STATUS "[RaZ] Profiling ENABLED")
else ()
message(STATUS "[RaZ] Profiling DISABLED")
endif ()

target_link_libraries(RaZ PRIVATE fastgltf simdjson stb)

# Compiling RaZ's sources
Expand Down
7 changes: 7 additions & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ if (RAZ_USE_LUA)
include(Sol2)
endif ()

include(Tracy)

option(RAZ_USE_PROFILING "Use profiling capabilities (with Tracy)" OFF)
if (RAZ_USE_PROFILING)
target_compile_definitions(Tracy PUBLIC TRACY_ENABLE)
endif ()

include(Catch2)
include(fastgltf)
include(stb)
2 changes: 0 additions & 2 deletions extern/Tracy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ target_sources(Tracy PRIVATE tracy/TracyClient.cpp)

target_include_directories(Tracy SYSTEM PUBLIC tracy)

target_compile_definitions(Tracy PUBLIC TRACY_ENABLE)

# Disabling all compilers warnings
if (RAZ_COMPILER_MSVC)
target_compile_options(Tracy PRIVATE /w)
Expand Down

0 comments on commit 5ce72c5

Please sign in to comment.