1From a439daafdc98391eed13e23f93ecfca81d71c731 Mon Sep 17 00:00:00 2001 2From: Fabrice Fontaine <fontaine.fabrice@gmail.com> 3Date: Mon, 2 Aug 2021 09:49:48 +0200 4Subject: [PATCH] CMakeLists.txt: add UA_FORCE_WERROR 5 6Allow the user to disable -Werror to avoid the following build failures: 7 8/tmp/instance-0/output-1/build/open62541-v1.2.2/arch/network_tcp.c: In function 'connection_recv': 9/tmp/instance-0/output-1/build/open62541-v1.2.2/arch/network_tcp.c:96:5: error: conversion to 'unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion] 10 96 | UA_fd_set(connection->sockfd, &fdset); 11 | ^~~~~~~~~ 12 13/tmp/instance-6/output-1/build/open62541-v1.2.2/plugins/ua_pubsub_udp.c: In function 'UA_PubSubChannelUDPMC_receive': 14/tmp/instance-6/output-1/build/open62541-v1.2.2/plugins/ua_pubsub_udp.c:477:21: error: conversion to '__suseconds_t' {aka 'int'} from 'UA_UInt32' {aka 'unsigned int'} may change the sign of the result [-Werror=sign-conversion] 15 477 | tmptv.tv_usec = (long int)(timeout % 1000000); 16 | ^ 17 18Fixes: 19 - http://autobuild.buildroot.org/results/911811de81d8abb2a31feb8f27af1592641c6fbc 20 - http://autobuild.buildroot.org/results/f0187b3f2d62e955fddeef4e90f84ba4fd642bd2 21 22Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 23[Upstream status: https://github.com/open62541/open62541/pull/4572] 24--- 25 CMakeLists.txt | 6 +++++- 26 1 file changed, 5 insertions(+), 1 deletion(-) 27 28diff --git a/CMakeLists.txt b/CMakeLists.txt 29index bc839f27..963460d0 100644 30--- a/CMakeLists.txt 31+++ b/CMakeLists.txt 32@@ -292,6 +292,8 @@ if(UA_FORCE_CPP) 33 add_definitions(-D__STDC_CONSTANT_MACROS) # We need the UINT32_C define 34 endif() 35 36+option(UA_FORCE_WERROR "Force compilation with -Werror" ON) 37+ 38 #General PubSub setup 39 option(UA_ENABLE_PUBSUB "Enable the PubSub protocol" OFF) 40 41@@ -589,7 +591,9 @@ if(NOT UA_FORCE_CPP AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" ST 42 check_add_cc_flag("-Wall") # Warnings 43 check_add_cc_flag("-Wextra") # More warnings 44 check_add_cc_flag("-Wpedantic") # Standard compliance 45- check_add_cc_flag("-Werror") # All warnings are errors 46+ if(UA_FORCE_WERROR) 47+ check_add_cc_flag("-Werror") # All warnings are errors 48+ endif() 49 50 check_add_cc_flag("-Wno-static-in-inline") # Clang doesn't like the use of static inline methods inside static inline methods 51 check_add_cc_flag("-Wno-overlength-strings") # May happen in the nodeset compiler when complex values are directly encoded 52-- 532.30.2 54 55