From 7f573bb334194ba3b61b1d68ed38e6d6b309523c Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Wed, 18 Mar 2020 16:26:30 -0400 Subject: [PATCH] build: Add WITH_BOOST_VALGRIND option To build Boost.Context (and other libraries) with support to allow them to be valground usefully, and to include the define to link against them. Signed-off-by: Adam C. Emerson --- CMakeLists.txt | 3 +++ cmake/modules/BuildBoost.cmake | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0b0b5b710791..d2eb972888714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -656,6 +656,9 @@ if(WITH_GRAFANA) add_subdirectory(monitoring/grafana/dashboards) endif() +CMAKE_DEPENDENT_OPTION(WITH_BOOST_VALGRIND "Boost support for valgrind" OFF + "NOT WITH_SYSTEM_BOOST" OFF) + include(CTags) option(CTAG_EXCLUDES "Exclude files/directories when running ctag.") add_tags(ctags diff --git a/cmake/modules/BuildBoost.cmake b/cmake/modules/BuildBoost.cmake index 2e92132366c6c..900e0e539e53e 100644 --- a/cmake/modules/BuildBoost.cmake +++ b/cmake/modules/BuildBoost.cmake @@ -131,6 +131,9 @@ function(do_build_boost version) list(APPEND b2 architecture=arm) list(APPEND b2 binary-format=elf) endif() + if(WITH_BOOST_VALGRIND) + list(APPEND b2 valgrind=on) + endif() set(build_command ${b2} headers stage #"--buildid=ceph" # changes lib names--can omit for static @@ -224,6 +227,10 @@ macro(build_boost version) INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}" IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${Boost_${upper_c}_LIBRARY}") + if(c MATCHES "coroutine|context") + set_target_properties(Boost::${c} PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_USE_VALGRIND") + endif() list(APPEND Boost_LIBRARIES ${Boost_${upper_c}_LIBRARY}) endforeach() foreach(c ${Boost_BUILD_COMPONENTS}) -- 2.39.5