From 624ae0ac26e889b126338041a3d28dd429fbd32c Mon Sep 17 00:00:00 2001 From: Matija Kecman Date: Fri, 10 Oct 2025 08:21:21 -0700 Subject: [PATCH] Silence warning/error relating to not using a const-ref in a for loop. PiperOrigin-RevId: 817652277 Change-Id: Ia700c67fe2c163c7a1e6e35fbbaed632cca213c3 --- cmake/MujocoDependencies.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake index c242b5a6..2b07a4c9 100644 --- a/cmake/MujocoDependencies.cmake +++ b/cmake/MujocoDependencies.cmake @@ -203,6 +203,16 @@ if(NOT TARGET trianglemeshdistance) FetchContent_GetProperties(trianglemeshdistance) if(NOT trianglemeshdistance_POPULATED) FetchContent_Populate(trianglemeshdistance) + # Patch the source code to silence a warning/error related to a loop variable creating a copy. + # Since this is a header only library this fix is less intrusive than disabling the warning for + # any target including the header. + set(TMD_HEADER ${trianglemeshdistance_SOURCE_DIR}/TriangleMeshDistance/include/tmd/TriangleMeshDistance.h) + file(READ ${TMD_HEADER} TMD_CONTENT) + string(REPLACE + "for (const auto edge_count : edges_count) {" + "for (const auto& edge_count : edges_count) {" + TMD_CONTENT "${TMD_CONTENT}") + file(WRITE ${TMD_HEADER} "${TMD_CONTENT}") include_directories(${trianglemeshdistance_SOURCE_DIR}) endif() endif()