2
1

0002-Add-option-JSONCPP_WITH_STRICT_ISO.patch 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From 9c5478562eba4bed32577a1dd7ce02b3bb7f6b4e Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
  3. Date: Thu, 29 Oct 2015 09:19:41 +0100
  4. Subject: [PATCH 1/1] Add option JSONCPP_WITH_STRICT_ISO
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. '-pedantic' issues all warnings demanded by strict ISO C/C++; rejecting
  9. extensions that do not follow ISO C/C++. Without this option, certain GNU
  10. extensions and traditional C/C++ features are supported as well.
  11. With this option enabled building jsoncpp fails with the musl toolchain on
  12. x86 because of an incompatible posix_memalign declaration [1]. Without
  13. '-pedantic' there is no error anymore and jsoncpp builds fine.
  14. Add an option JSONCPP_WITH_STRICT_ISO to disable compilation with '-pedantic'
  15. with GCC. If jsoncpp is build with the JSONCPP_WITH_WARNING_AS_ERROR option
  16. '-pedantic-errors' is used instead.
  17. [1] https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01425.html
  18. Backported from: 48bfe910622d79507983fc36254ca9f3ca63acb6
  19. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
  20. ---
  21. CMakeLists.txt | 10 +++++++++-
  22. 1 file changed, 9 insertions(+), 1 deletion(-)
  23. diff --git a/CMakeLists.txt b/CMakeLists.txt
  24. index 62bf203..60ecb6f 100644
  25. --- a/CMakeLists.txt
  26. +++ b/CMakeLists.txt
  27. @@ -7,6 +7,7 @@ ENABLE_TESTING()
  28. OPTION(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
  29. OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
  30. OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
  31. +OPTION(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C and ISO C++" ON)
  32. OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
  33. OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
  34. OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
  35. @@ -83,6 +84,9 @@ macro(UseCompilationWarningAsError)
  36. # Only enabled in debug because some old versions of VS STL generate
  37. # warnings when compiled in release configuration.
  38. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
  39. + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  40. + if (JSONCPP_WITH_STRICT_ISO)
  41. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
  42. endif( MSVC )
  43. endmacro()
  44. @@ -100,8 +104,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  45. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wno-sign-conversion")
  46. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  47. # using GCC
  48. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra -pedantic")
  49. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra")
  50. # not yet ready for -Wsign-conversion
  51. +
  52. + if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
  53. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  54. + endif ()
  55. endif()
  56. IF(JSONCPP_WITH_WARNING_AS_ERROR)
  57. --
  58. 2.6.2