Declare qt headers as system headers with CMake

I am using CMake with qt saying:

find_package(Qt5 COMPONENTS Widgets)

In addition, I want to use a high level of warning, and I want to treat warnings as errors. Therefore, I use:

set( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra" )

However, I do not care about the warnings in the libraries that I use. So, for example, to enable boost, I prepend SYSTEMin the call include_directories, so I'm not worried about warnings from an external library:

include_directories(SYSTEM ${Boost_INCLUDE_DIR} )

But it does not work for qt, since there is no explicit expression include_directories which I might add SYSTEM.

What can I do about it? I found a request for this function here: http://www.itk.org/Bug/print_bug_page.php?bug_id=8710

+4
1

- CMAKE_CXX_FLAGS. , , .

COMPILE_FLAGS, target file :

set_property(TARGET <your_target_goes_here> 
             APPEND PROPERTY COMPILE_FLAGS "-Werror -Wall -Wextra")

, , CMake .

CMake 3 , target_compile_options :

target_compile_options(<your_target_goes_here> PRIVATE -Werror -Wall -Wextra)
+4

All Articles