Skip to content

Commit

Permalink
Reintroduce the option to profile with Tracy
Browse files Browse the repository at this point in the history
  • Loading branch information
victorreijgwart committed Nov 22, 2024
1 parent d7a20b3 commit 75f4edf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions interfaces/ros1/wavemap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../library/cpp

# Include the library's tests in catkin's run_tests target
include(cmake/append_to_catkin_tests.cmake)
append_to_catkin_tests(test_wavemap_io)
append_to_catkin_tests(test_wavemap_core)
append_to_catkin_tests(test_wavemap_io)

# Support installs
# Mark targets for installation
Expand All @@ -38,6 +38,6 @@ install(TARGETS wavemap_core wavemap_io wavemap_pipeline
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
# Mark headers for installation
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/../../../library/cpp/include/wavemap/
"${CMAKE_CURRENT_SOURCE_DIR}/../../../library/cpp/include/wavemap/"
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h")
1 change: 1 addition & 0 deletions library/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option(BUILD_SHARED_LIBS
option(USE_SYSTEM_EIGEN "Use system pre-installed Eigen" ON)
option(USE_SYSTEM_GLOG "Use system pre-installed glog" ON)
option(USE_SYSTEM_BOOST "Use system pre-installed Boost" ON)
option(TRACY_ENABLE "Enable profiling with Tracy" OFF)

# CMake helpers and general wavemap tooling (e.g. to run clang-tidy CI)
include(GNUInstallDirs)
Expand Down
12 changes: 11 additions & 1 deletion library/cpp/cmake/find-wavemap-deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@ else ()
endif ()

# Optional dependencies
find_package(tracy QUIET)
if (TRACY_ENABLE)
find_package(Tracy QUIET)
if (NOT Tracy_FOUND)
message(FATAL_ERROR
"Profiling is enabled (TRACY_ENABLE=ON), but Tracy is not available. "
"Please switch it to OFF or install Tracy as a system package with: "
"cmake -S . -B build -DTRACY_ENABLE=ON -DBUILD_SHARED_LIBS=true "
"-DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel && "
"sudo make install")
endif ()
endif ()
5 changes: 5 additions & 0 deletions library/cpp/cmake/wavemap-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function(set_wavemap_target_properties target)
# General C++ defines
target_compile_definitions(${target} PUBLIC EIGEN_INITIALIZE_MATRICES_BY_NAN)

# Profiling related C++ defines
if (TRACY_ENABLE)
target_compile_definitions(${target} PUBLIC TRACY_ENABLE)
endif ()

# Conditional compilation options
if (DCHECK_ALWAYS_ON)
target_compile_definitions(${target} PUBLIC DCHECK_ALWAYS_ON)
Expand Down
4 changes: 2 additions & 2 deletions library/cpp/src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set_wavemap_target_properties(wavemap_core)
add_wavemap_include_directories(wavemap_core)
target_link_libraries(wavemap_core
PUBLIC Eigen3::Eigen glog Boost::preprocessor)
if (tracy_FOUND)
target_link_libraries(wavemap_core PUBLIC TracyClient)
if (Tracy_FOUND)
target_link_libraries(wavemap_core PUBLIC TracyClient dl)
endif ()

# Set sources
Expand Down

0 comments on commit 75f4edf

Please sign in to comment.