cmake.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index e0f12eb1e..b4b62d3c0 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -73,7 +73,8 @@ if(PROJECT_IS_TOP_LEVEL)
  6. option(BOX2D_PROFILE "Enable profiling with Tracy" OFF)
  7. option(BOX2D_VALIDATE "Enable heavy validation" ON)
  8. option(BOX2D_UNIT_TESTS "Build the Box2D unit tests" ON)
  9. -
  10. + option(BOX2D_COMPILE_WARNING_AS_ERROR "Compile warnings as errors" OFF)
  11. +
  12. if(MSVC AND WIN32)
  13. # add_compile_options(/fsanitize=address)
  14. # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/GS- /Gy /O2 /Oi /Ot")
  15. diff --git a/shared/CMakeLists.txt b/shared/CMakeLists.txt
  16. index 9a9e98082..f0c050116 100644
  17. --- a/shared/CMakeLists.txt
  18. +++ b/shared/CMakeLists.txt
  19. @@ -17,6 +17,10 @@ set_target_properties(shared PROPERTIES
  20. C_STANDARD 17
  21. )
  22. +if (BOX2D_COMPILE_WARNING_AS_ERROR)
  23. + set_target_properties(shared PROPERTIES COMPILE_WARNING_AS_ERROR ON)
  24. +endif()
  25. +
  26. target_include_directories(shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
  27. target_link_libraries(shared PRIVATE box2d)
  28. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  29. index 5e08afae0..dbc41b129 100644
  30. --- a/src/CMakeLists.txt
  31. +++ b/src/CMakeLists.txt
  32. @@ -92,12 +92,15 @@ set_target_properties(box2d PROPERTIES
  33. C_STANDARD 17
  34. C_STANDARD_REQUIRED YES
  35. C_EXTENSIONS YES
  36. - COMPILE_WARNING_AS_ERROR ON
  37. VERSION ${PROJECT_VERSION}
  38. SOVERSION ${PROJECT_VERSION_MAJOR}
  39. DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
  40. )
  41. +if (BOX2D_COMPILE_WARNING_AS_ERROR)
  42. + set_target_properties(box2d PROPERTIES COMPILE_WARNING_AS_ERROR ON)
  43. +endif()
  44. +
  45. if (BOX2D_PROFILE)
  46. target_compile_definitions(box2d PRIVATE BOX2D_PROFILE)
  47. @@ -160,15 +163,15 @@ elseif (MINGW)
  48. endif()
  49. elseif (APPLE)
  50. message(STATUS "Box2D on Apple")
  51. - target_compile_options(box2d PRIVATE -Wmissing-prototypes -Wall -Wextra -pedantic -Werror)
  52. + target_compile_options(box2d PRIVATE -Wmissing-prototypes -Wall -Wextra -pedantic)
  53. elseif (EMSCRIPTEN)
  54. message(STATUS "Box2D on Emscripten")
  55. - if (BOX2D_DISABLE_SIMD OFF)
  56. + if (NOT BOX2D_DISABLE_SIMD)
  57. target_compile_options(box2d PRIVATE -msimd128 -msse2)
  58. endif()
  59. elseif (UNIX)
  60. message(STATUS "Box2D using Unix")
  61. - target_compile_options(box2d PRIVATE -Wmissing-prototypes -Wall -Wextra -pedantic -Werror -Wno-unused-value)
  62. + target_compile_options(box2d PRIVATE -Wmissing-prototypes -Wall -Wextra -pedantic -Wno-unused-value)
  63. if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
  64. # raspberry pi
  65. # -mfpu=neon
  66. diff --git a/src/distance.c b/src/distance.c
  67. index 415ca80c2..1e1e5341c 100644
  68. --- a/src/distance.c
  69. +++ b/src/distance.c
  70. @@ -218,10 +218,6 @@ static void b2ComputeSimplexWitnessPoints( b2Vec2* a, b2Vec2* b, const b2Simplex
  71. {
  72. switch ( s->count )
  73. {
  74. - case 0:
  75. - B2_ASSERT( false );
  76. - break;
  77. -
  78. case 1:
  79. *a = s->v1.wA;
  80. *b = s->v1.wB;
  81. @@ -240,6 +236,8 @@ static void b2ComputeSimplexWitnessPoints( b2Vec2* a, b2Vec2* b, const b2Simplex
  82. break;
  83. default:
  84. + *a = b2Vec2_zero;
  85. + *b = b2Vec2_zero;
  86. B2_ASSERT( false );
  87. break;
  88. }