Silence warning/error relating to not using a const-ref in a for loop.

PiperOrigin-RevId: 817652277
Change-Id: Ia700c67fe2c163c7a1e6e35fbbaed632cca213c3
This commit is contained in:
Matija Kecman
2025-10-10 08:21:21 -07:00
committed by Copybara-Service
parent ff7c613c79
commit 624ae0ac26
+10
View File
@@ -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()