Skip to content

Commit

Permalink
feat: Add build options for enabling profiling (acts-project#1273)
Browse files Browse the repository at this point in the history
Separate build options for enabling CPU and memory profiling are enabled
They link the libraries used by the tools as this is the simplest way
and follows established style
  • Loading branch information
Scott-James-Hurley committed May 27, 2022
1 parent a7ee09d commit a003fb6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ option(ACTS_USE_SYSTEM_BOOST "Use a system-provided boost" ON)
option(ACTS_SETUP_EIGEN3 "Explicitly set up Eigen3 for the project" ON)
option(ACTS_USE_SYSTEM_EIGEN3 "Use a system-provided eigen3" ON)
option(ACTS_BUILD_ODD "Build the OpenDataDetector" OFF)
# profiling related optios
option(ACTS_ENABLE_CPU_PROFILING "Enable CPU profiling using gperftools" OFF)
option(ACTS_ENABLE_MEMORY_PROFILING "Enable memory profiling using gperftools" OFF)

# handle option inter-dependencies and the everything flag
# NOTE: ordering is important here. dependencies must come before dependees
Expand Down Expand Up @@ -339,6 +342,12 @@ if(ACTS_BUILD_BENCHMARKS OR ACTS_BUILD_INTEGRATIONTESTS OR ACTS_BUILD_UNITTESTS)
add_subdirectory(Tests)
endif()

#generate debug information
if(ACTS_ENABLE_CPU_PROFILING)
message(STATUS "Added -g compile flag")
add_compile_options(-g)
endif()

# documentation
add_subdirectory_if(docs ACTS_BUILD_DOCS)

Expand Down
18 changes: 18 additions & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ if(ACTS_LOG_FAILURE_THRESHOLD)
PUBLIC -DACTS_LOG_FAILURE_THRESHOLD=${ACTS_LOG_FAILURE_THRESHOLD})
endif()

if(ACTS_ENABLE_CPU_PROFILING)
message(STATUS "added lprofiler")
target_link_libraries(
ActsCore
PUBLIC -lprofiler)

target_link_options(
ActsCore
PUBLIC "LINKER:-no-as-needed")
endif()

if(ACTS_ENABLE_MEMORY_PROFILING)
message(STATUS "added ltcmalloc")
target_link_libraries(
ActsCore
PUBLIC -ltcmalloc)
endif()

install(
TARGETS ActsCore
EXPORT ActsCoreTargets
Expand Down

0 comments on commit a003fb6

Please sign in to comment.