You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2021/03/11 13:16:37 UTC

[qpid-proton] branch master updated: PROTON-2343: Tidy up build flag selection

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/master by this push:
     new 51b0070  PROTON-2343: Tidy up build flag selection
51b0070 is described below

commit 51b007059dead6c8fada8f3fe4ac139dc290705f
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Fri Oct 16 16:28:46 2020 -0400

    PROTON-2343: Tidy up build flag selection
    
    It should now be much clearer what build flags apply to which builds
---
 CMakeLists.txt     | 81 ++++++++++++++++++++++++++++++++----------------------
 c/CMakeLists.txt   | 16 +----------
 cpp/CMakeLists.txt |  4 ---
 3 files changed, 49 insertions(+), 52 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d12323..c5586a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -181,44 +181,59 @@ set (LINK_LTO_GNU "-flto -fno-fat-lto-objects")
 set (LINK_LTO_Clang "-flto=thin")
 set (LINK_LTO_MSVC "/LTCG")
 
+set (WERROR_GNU "-Werror")
+set (WERROR_Clang "-Werror")
+set (WERROR_MSVC "")
+
+set (COMMON_WARNING_GNU "-Wall -pedantic-errors")
+set (COMMON_WARNING_Clang "-Wall -pedantic")
+set (COMMON_WARNING_MSVC "")
+
+set (CC_WARNING_GNU "-Wno-unused-parameter -Wstrict-prototypes -Wvla -Wsign-compare -Wwrite-strings")
+set (CC_WARNING_Clang "-Wno-unused-parameter -Wstrict-prototypes -Wvla -Wsign-compare -Wwrite-strings")
+set (CC_WARNING_MSVC "/wd4244 /wd4267 /wd4800 /wd4996")
+
+set (CXX_WARNING_GNU "")
+# TODO aconway 2016-01-06: we should be able to clean up the code and turn on
+# some of these warnings.
+#set (CXX_WARNING_Clang "-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-padded -Wno-sign-conversion -Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors -Wno-global-constructors -Wno-shorten-64-to-32 -Wno-documentation -Wno-documentation-unknown-command -Wno-old-style-cast -Wno-missing-noreturn")
+set (CXX_WARNING_Clang "")
+set (CXX_WARNING_MSVC "")
+
+set (CATCH_UNDEFINED_Linux "-Wl,--no-undefined")
+set (CATCH_UNDEFINED_FreeBSD "-Wl,--no-undefined")
+set (CATCH_UNDEFINED_Darwin "-Wl,-undefined,error")
+set (CATCH_UNDEFINED_Windows "")
+
+set (HIDE_SYMBOLS_GNU "-fvisibility=hidden")
+set (HIDE_SYMBOLS_Clang "-fvisibility=hidden")
+set (HIDE_SYMBOLS_SunPro "-xldscope=hidden")
+
 if (ENABLE_LINKTIME_OPTIMIZATION)
   set (LTO ${LTO_${CMAKE_C_COMPILER_ID}})
   set (LINK_LTO ${LINK_LTO_${CMAKE_C_COMPILER_ID}})
 endif (ENABLE_LINKTIME_OPTIMIZATION)
 
-if (CMAKE_COMPILER_IS_GNUCC)
-  if (ENABLE_WARNING_ERROR)
-    set (WERROR "-Werror")
-  endif (ENABLE_WARNING_ERROR)
-  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors")
-  set (CXX_WARNING_FLAGS "${COMPILE_WARNING_FLAGS}")
-  set (COMPILE_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wstrict-prototypes -Wvla -Wsign-compare -Wwrite-strings")
-
-  if (ENABLE_UNDEFINED_ERROR)
-    set (CATCH_UNDEFINED "-Wl,--no-undefined")
-    set (ALLOW_UNDEFINED "-Wl,--allow-shlib-undefined")
-  endif (ENABLE_UNDEFINED_ERROR)
-
-  if (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
-  endif (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
-elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
-  if (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xldscope=hidden")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xldscope=hidden")
-  endif (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
-endif (CMAKE_COMPILER_IS_GNUCC)
-
-if (CMAKE_C_COMPILER_ID MATCHES "Clang")
-  set (COMPILE_WARNING_FLAGS  "-Wall -pedantic")
-  if (ENABLE_WARNING_ERROR)
-    set (COMPILE_WARNING_FLAGS "-Werror ${COMPILE_WARNING_FLAGS}")
-  endif (ENABLE_WARNING_ERROR)
-  # TODO aconway 2016-01-06: we should be able to clean up the code and turn on
-  # some of these warnings.
-  set (CXX_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-padded -Wno-sign-conversion -Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors -Wno-global-constructors -Wno-shorten-64-to-32 -Wno-documentation -Wno-documentation-unknown-command -Wno-old-style-cast -Wno-missing-noreturn")
-endif()
+if (ENABLE_WARNING_ERROR)
+  set (WERROR ${WERROR_${CMAKE_C_COMPILER_ID}})
+endif (ENABLE_WARNING_ERROR)
+
+if (ENABLE_UNDEFINED_ERROR)
+  set (CATCH_UNDEFINED ${CATCH_UNDEFINED_${CMAKE_SYSTEM_NAME}})
+endif (ENABLE_UNDEFINED_ERROR)
+
+if (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIDE_SYMBOLS_${CMAKE_C_COMPILER_ID}}")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIDE_SYMBOLS_${CMAKE_C_COMPILER_ID}}")
+endif (ENABLE_HIDE_UNEXPORTED_SYMBOLS)
+
+set (COMMON_WARNING_FLAGS ${COMMON_WARNING_${CMAKE_C_COMPILER_ID}})
+set (CXX_WARNING_FLAGS "${WERROR} ${COMMON_WARNING_FLAGS} ${CXX_WARNING_${CMAKE_C_COMPILER_ID}}")
+set (COMPILE_WARNING_FLAGS "${WERROR} ${COMMON_WARNING_FLAGS} ${CC_WARNING_${CMAKE_C_COMPILER_ID}}")
+
+if (MSVC)
+  set(CMAKE_DEBUG_POSTFIX "d")
+endif (MSVC)
 
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   if (NOT CMAKE_OSX_ARCHITECTURES)
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt
index 56549b6..2146a5c 100644
--- a/c/CMakeLists.txt
+++ b/c/CMakeLists.txt
@@ -165,22 +165,8 @@ if (PN_WINAPI)
   list(APPEND PLATFORM_DEFINITIONS "PN_WINAPI")
 endif (PN_WINAPI)
 
-if (MSVC)
-    set(CMAKE_DEBUG_POSTFIX "d")
-    add_definitions(
-        /wd4244
-        /wd4267
-        /wd4800
-        /wd4996
-    )
-endif (MSVC)
-
-# Ensure that examples build with c99 on gcc/clang
-set(C_EXAMPLE_FLAGS_GNU "-pedantic")
-set(C_EXAMPLE_FLAGS_Clang "-pedantic")
-
 # Flags for example self-test build
-set(C_EXAMPLE_FLAGS "${COMPILE_WARNING_FLAGS} ${C_EXAMPLE_FLAGS_${CMAKE_C_COMPILER_ID}}")
+set(C_EXAMPLE_FLAGS "${C_STANDARD_FLAGS} ${COMPILE_WARNING_FLAGS}")
 set(C_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}")
 
 set(qpid-proton-platform_GNU src/compiler/gcc/start.c)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index c11a29f..ae9e923 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -150,10 +150,6 @@ set(qpid-proton-cpp-source
   ${CONNECT_CONFIG_SRC}
   )
 
-if (MSVC)
-  set (CMAKE_DEBUG_POSTFIX "d")
-endif ()
-
 add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source})
 if(BUILD_STATIC_LIBS)
   add_library(qpid-proton-cpp-static STATIC ${qpid-proton-cpp-source})


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org