diff --git a/CMakeLists.txt b/CMakeLists.txt
index 62935bd902d69e51716503635ea08ad50da056ee..e972c6c53b9fc22ac00819832d5873209ccc5d95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,3 +98,9 @@ target_link_libraries(fp311online PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets ROOT::H
 set_property(TARGET fp311online PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET fp311online PROPERTY CXX_VISIBILITY_PRESET hidden)
 set_property(TARGET fp311online PROPERTY VISIBILITY_INLINES_HIDDEN ON)
+
+if (${ROOT_VERSION} VERSION_GREATER_EQUAL 6.24)
+  # The interface of RooDataHist was improved in ROOT 6.24 and the old way of
+  # querying the content of a bin was deprecated.
+  target_compile_definitions(fp311online PUBLIC ROOT_6_24_OR_NEWER)
+endif (${ROOT_VERSION} VERSION_GREATER_EQUAL 6.24)