chmod 644 %{SOURCE0}
%setup -q
+# Add gcc version check as stringop-overflow stringop-truncation warnings are not introduced by GCC-6
+%define gccversion %(gcc -dumpversion | cut -f1 -d.)
+
+%if %{gccversion} >= 9
+ %define extraflags "-Wno-error=stringop-overflow -Wno-error=sizeof-pointer-memaccess -Wno-error=array-bounds -Wno-error=stringop-truncation"
+%else
+ %define extraflags "-Wno-error=sizeof-pointer-memaccess -Wno-error=array-bounds"
+%endif
+
+echo %{extraflags}
+
cmake . \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DLIB_INSTALL_DIR=%{_libdir} \
-DEMULD_MAJOR_VERSION=%{emuld_major_version} \
-DEMULD_MINOR_VERSION=%{emuld_minor_version} \
-DEMULD_RELEASE_NUMBER=%{emuld_release_number} \
- -DEXTRA_CFLAGS="-Wno-error=stringop-overflow -Wno-error=sizeof-pointer-memaccess -Wno-error=array-bounds -Wno-error=stringop-truncation"
+ -DEXTRA_CFLAGS=%{extraflags}
%build