Skip to content

Commit

Permalink
build: Add a build option for profiling (#4432)
Browse files Browse the repository at this point in the history
Right now, the only option is gperftools, because that's what I happened
to be trying. But this can be expanded later.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz committed Sep 21, 2024
1 parent dc663b5 commit 639089a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@ if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
endif ()


###########################################################################
# Profiling
#
set_cache (PROFILER "" "Build executables with profiler support (choices: gperftools)")
if (PROFILER STREQUAL "gperftools")
find_library(PROFILER_LIBRARIES NAMES profiler)
message (STATUS "Compiling for profiling with ${PROFILER}, found ${PROFILER_LIBRARIES}")
endif ()


###########################################################################
# Sanitizer options
#
Expand Down
13 changes: 4 additions & 9 deletions src/cmake/fancy_add_executable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,14 @@ macro (fancy_add_executable)
check_is_enabled (${_target_NAME} _target_NAME_enabled)
if (_target_NAME_enabled)
add_executable (${_target_NAME} ${_target_SRC})
if (_target_INCLUDE_DIRS)
target_include_directories (${_target_NAME} PRIVATE ${_target_INCLUDE_DIRS})
endif ()
if (_target_SYSTEM_INCLUDE_DIRS)
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
endif ()
target_include_directories (${_target_NAME} PRIVATE ${_target_INCLUDE_DIRS})
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
target_compile_definitions (${_target_NAME} PRIVATE
${_target_DEFINITIONS})
target_compile_options (${_target_NAME} PRIVATE
${_target_COMPILE_OPTIONS})
if (_target_LINK_LIBRARIES)
target_link_libraries (${_target_NAME} PRIVATE ${_target_LINK_LIBRARIES})
endif ()
target_link_libraries (${_target_NAME} PRIVATE ${_target_LINK_LIBRARIES})
target_link_libraries (${_target_NAME} PRIVATE ${PROFILER_LIBRARIES})
set_target_properties (${_target_NAME} PROPERTIES FOLDER ${_target_FOLDER})
check_is_enabled (INSTALL_${_target_NAME} _target_NAME_INSTALL_enabled)
if (CMAKE_UNITY_BUILD AND UNITY_BUILD_MODE STREQUAL GROUP)
Expand Down

0 comments on commit 639089a

Please sign in to comment.