Skip to content

Commit fd0dd23

Browse files
j-riveroscpeters
andauthored
Fix Windows MSVC C4250 warnings from DART headers (#837)
Add /wd4250 compiler flag to suppress 'inherits via dominance' warnings that originate from DART library headers. These warnings cannot be fixed in gz-physics code as they come from the external DART dependency. Changes: - Use target_compile_options instead of CMAKE_CXX_FLAGS in TPE plugin - Add C4250 suppression to dartsim unit tests - Add C4250 suppression to bullet unit tests - Add C4250 suppression to TPE unit tests - Add C4250 suppression to integration tests This ensures a clean Windows build without hiding legitimate warnings. Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com> Co-authored-by: Steve Peters <scpeters@openrobotics.org>
1 parent ddc8c9f commit fd0dd23

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

bullet/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ foreach(test ${tests})
6262
"TEST_WORLD_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/worlds/\""
6363
"IGNITION_PHYSICS_RESOURCE_DIR=\"${IGNITION_PHYSICS_RESOURCE_DIR}\"")
6464

65+
if (MSVC)
66+
# disable MSVC inherit via dominance warning
67+
target_compile_options(${test} PRIVATE "/wd4250")
68+
endif()
69+
6570
endforeach()
6671

6772
if(TARGET UNIT_FindFeatures_TEST)

dartsim/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ foreach(test ${tests})
100100
target_compile_definitions(${test} PRIVATE DART_HAS_CONTACT_SURFACE)
101101
endif()
102102

103+
if (MSVC)
104+
# disable MSVC inherit via dominance warning from DART headers
105+
target_compile_options(${test} PRIVATE "/wd4250")
106+
endif()
107+
103108
# Helps when we want to build a single test after making changes to dartsim_plugin
104109
add_dependencies(${test} ${dartsim_plugin})
105110
endforeach()

test/integration/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ if (BUILD_TESTING)
3535

3636
endforeach()
3737

38+
if (MSVC)
39+
# disable MSVC inherit via dominance warning
40+
target_compile_options(${test} PRIVATE "/wd4250")
41+
endif()
42+
3843
endforeach()
3944
endif()
4045

tpe/plugin/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ set(versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${tpe_plugin}${CMAKE_SHARED_LIBRARY_
4141
set(unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
4242
if (WIN32)
4343
# disable MSVC inherit via dominance warning
44-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250")
44+
target_compile_options(${tpe_plugin} PUBLIC "/wd4250")
4545
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy
4646
${IGNITION_PHYSICS_ENGINE_INSTALL_DIR}\/${versioned}
4747
${IGNITION_PHYSICS_ENGINE_INSTALL_DIR}\/${unversioned})")
@@ -69,4 +69,9 @@ foreach(test ${tests})
6969
"TEST_WORLD_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/worlds/\""
7070
"IGNITION_PHYSICS_RESOURCE_DIR=\"${IGNITION_PHYSICS_RESOURCE_DIR}\"")
7171

72+
if (MSVC)
73+
# disable MSVC inherit via dominance warning
74+
target_compile_options(${test} PRIVATE "/wd4250")
75+
endif()
76+
7277
endforeach()

0 commit comments

Comments
 (0)