0001-CMakeLists-fix-build-with-old-compilers.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 77b78e01f83b65f3c38941f54f71beaaddcb6fc1 Mon Sep 17 00:00:00 2001
  2. From: Pierre-Jean Texier <pjtexier@koncepto.io>
  3. Date: Sat, 23 Nov 2019 16:51:46 +0100
  4. Subject: [PATCH] CMakeLists: fix build with old compilers
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The librsync code uses some C99 constructs, but old compilers such
  9. as gcc 4.7 don't default to -std=c99. This commit makes sure librsync
  10. is built with -std=gnu99.
  11. Fixes:
  12. src/rabinkarp.h:82:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
  13. for (size_t i = len; i; i--) {
  14. ^
  15. src/rabinkarp.h:82:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
  16. Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
  17. [Upstream status: https://github.com/librsync/librsync/pull/181]
  18. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  19. ---
  20. CMakeLists.txt | 2 +-
  21. 1 file changed, 1 insertion(+), 1 deletion(-)
  22. diff --git a/CMakeLists.txt b/CMakeLists.txt
  23. index f810061..794d9c0 100644
  24. --- a/CMakeLists.txt
  25. +++ b/CMakeLists.txt
  26. @@ -149,7 +149,7 @@ if (CMAKE_C_COMPILER_ID MATCHES "(Clang|Gnu|GNU)")
  27. # TODO: Set for MSVC and other compilers.
  28. # TODO: Set -Werror when the build is clean.
  29. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
  30. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99")
  31. endif()
  32. site_name(BUILD_HOSTNAME)