1

How to disable warnings of GCC compiler both in header and source files?

In main CMakeLisits.txt:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++ -std=c++11")

...

add_subdirectory(lib)

In lib CMakeLisits.txt:

set(lib_SOURCES

...)

include_directories(${lib_SOURCE_DIR}/include ${lib_BINARY_DIR}/include)
add_library(ilib STATIC ${ilib_EXTRA_CFLAGS} ${ilib_SOURCES})

...
..

I've tried add in lib CMakeLists.txt

include_directories(SYSTEM ${lib_SOURCE_DIR}/include ${lib_BINARY_DIR}/include)

and it helped with headers, but I still have warnings in *.cpp files

Then I tried

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-effc++")

in lib, CMakeLists.txt, and warnings in header appeared again

Don't understand what's happening

CMake version 2.8.12.2
gcc version 4.9.3
Adnan
  • 2,931
  • 3
  • 23
  • 35
krokodil
  • 11
  • 3
  • 1
    Welcome to Stack Overflow. Please read the [About] and [Ask] pages soon. Why don't you fix the code so that there are no warnings? What warnings appear? What code triggers those warnings? You really haven't provided enough information for anyone to be able to help you. – Jonathan Leffler Jul 12 '16 at 05:36
  • Please provide a minmal example which shows your problem. So a small but complete cpp and CMakeLists.txt file. – usr1234567 Jul 12 '16 at 06:28
  • There could be many reasons why this could not work (for more details on how to modify CXX flags see [here](http://stackoverflow.com/questions/33828855/is-cmake-set-variable-recursive)). Please provide a [mcve]. A more general solution for CMake projects: I like the [Cross platform warning suppression](https://github.com/ruslo/sugar/wiki/Cross-platform-warning-suppression) work from [@ruslo](http://stackoverflow.com/users/2288008/ruslo). – Florian Jul 12 '16 at 07:24

0 Answers0