From 76933690b04b7de11dddfb458c802522c154dd30 Mon Sep 17 00:00:00 2001 From: jmayer Date: Thu, 23 Aug 2012 12:30:16 +0000 Subject: The proper way to set compiler flags in cmake is not by using add_definitions() but the variables CMAKE_C{,XX}_FLAGS. Set these flags correctly at the toplevel, so no hack in the ui/qt/ subdir is required anymore. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@44633 f5534014-38df-0310-8fa8-9805f1628bb7 --- CMakeLists.txt | 21 ++++++++++++++++++++- ui/qt/CMakeLists.txt | 7 ------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfbbab1a0c..edd7619f0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,9 @@ set(WIRESHARK_C_FLAGS -Wcast-align -Wformat-security -fexcess-precision=fast +) +set(WIRESHARK_C_ONLY_FLAGS # The following are C only, not C++ -Wdeclaration-after-statement -Wno-pointer-sign @@ -150,6 +152,9 @@ set(WIRESHARK_EXTRA_C_FLAGS # More cleanup needed for this on LP64 -Wshorten-64-to-32 +) + +set(WIRESHARK_EXTRA_C_ONLY_FLAGS # The following are C only, not C++ -Wbad-function-cast -Wc++-compat @@ -162,6 +167,7 @@ set(WIRESHARK_EXTRA_C_FLAGS if(ENABLE_EXTRA_GCC_CHECKS) # This overrides -Werror set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS}) + set(WIRESHARK_C_ONLY_FLAGS ${WIRESHARK_C_ONLY_FLAGS} ${WIRESHARK_EXTRA_C_ONLY_FLAGS}) endif() add_definitions( @@ -180,10 +186,23 @@ foreach(THIS_FLAG ${WIRESHARK_C_FLAGS}) set(V WS_C_FLAG_VALID${C}) check_c_compiler_flag(${${F}} ${V}) if (${${V}}) - add_definitions(${${F}}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${F}}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${F}}") + endif() + math(EXPR C "${C} + 1") +endforeach() +# Continue increasing C from previous loop +foreach(THIS_FLAG ${WIRESHARK_C_ONLY_FLAGS}) + set(F WS_C_FLAG_${C}) + set(${F} ${THIS_FLAG}) + set(V WS_C_FLAG_VALID${C}) + check_c_compiler_flag(${${F}} ${V}) + if (${${V}}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${F}}") endif() math(EXPR C "${C} + 1") endforeach() +message(STATUS "C-Flags: ${CMAKE_C_FLAGS}\nCXX-Flags: ${CMAKE_CXX_FLAGS}") if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS) check_c_compiler_flag(-Werror WERROR) diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 2b686a658d..e7971f0cc0 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -137,13 +137,6 @@ endif() add_definitions(${QT_DEFINITIONS}) -# Get rid of C-only compile flags -remove_definitions( - -Wdeclaration-after-statement - -Wno-pointer-sign - -Wold-style-definition -) - add_library(qtui STATIC ${QTSHARK_SRC} ${QTSHARK_UI_SRC} -- cgit v1.2.3