[Openvpn-devel,2/4,CMake] Only add -Wno-stringop-truncation on supported compilers
Commit Message
The -Wno-stringop-truncation flag is only supported by some GCC versions
and not by Clang (macOS, FreeBSD) at all.
Move the includes to the top the file to have them available when running
the check_c_compiler_flag.
Change-Id: I452bc4ee935d13f8e9095d0a31805a3bbaff0cec
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
CMakeLists.txt | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
Comments
On Thu, Jun 29, 2023 at 11:56:08PM +0200, Arne Schwabe wrote:
> The -Wno-stringop-truncation flag is only supported by some GCC versions
> and not by Clang (macOS, FreeBSD) at all.
>
> Move the includes to the top the file to have them available when running
> the check_c_compiler_flag.
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Your patch has been applied to the master branch.
commit eb3cd5ea36f9bf235da7b8a51fd6ce29780f0e39
Author: Arne Schwabe
Date: Thu Jun 29 23:56:08 2023 +0200
Only add -Wno-stringop-truncation on supported compilers
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230629215611.3292788-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26791.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
@@ -12,6 +12,14 @@ project(openvpn)
# and OpenSSL having version 1.1.1+ and generally does not offer the same
# configurability like autoconf
+find_package(PkgConfig REQUIRED)
+include(CheckSymbolExists)
+include(CheckIncludeFiles)
+include(CheckCCompilerFlag)
+include(CheckTypeSize)
+include(CheckStructHasMember)
+include(CTest)
+
option(UNSUPPORTED_BUILDS "Allow unsupported builds" OFF)
if (NOT WIN32 AND NOT ${UNSUPPORTED_BUILDS})
@@ -70,7 +78,12 @@ else ()
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG "-g -O1")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O1")
- add_compile_options(-Wall -Wuninitialized -Wno-stringop-truncation)
+ add_compile_options(-Wall -Wuninitialized)
+ check_c_compiler_flag(-Wno-stringop-truncation NoStringOpTruncation)
+
+ if (${NoStringOpTruncation})
+ add_compile_options(-Wno-stringop-truncation)
+ endif()
# We are not ready for this
#add_compile_options(-Wconversion -Wno-sign-conversion -Wsign-compare)
if (USE_WERROR)
@@ -78,13 +91,6 @@ else ()
endif ()
endif ()
-find_package(PkgConfig REQUIRED)
-include(CheckSymbolExists)
-include(CheckIncludeFiles)
-include(CheckTypeSize)
-include(CheckStructHasMember)
-include(CTest)
-
find_program(PYTHON NAMES python3 python)
execute_process(
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/parse-version.m4.py ${CMAKE_CURRENT_SOURCE_DIR}/version.m4