I have a project that uses VTK as an external library. In my own source code, is use -Werror to ensure that those are always fixed. In order to do this "checking" in my code, external libraries are loaded in CMake with the INCLUDE_DIRECTORIES directive using the parameter SYSTEM. But if some external library is loaded through a CMakeLists.txt file (as VTK is)? I cannot specify that specify that VTK is a SYSTEM library and therefore VTK warnings are shown as errors. Is there a way to disable warnings from included libraries?
2 Answers
VTK adds include_directories itself, so unless you change VTK's CMake file with that line, you will most probably have to change your included directories property with some string operations. A faster way that worked for me is to change the line in VTK with include_directories, namely lib/cmake/vtk-*/UseVTK.cmake - the one you include with include(${VTK_USE_FILE}). I just changed the line
# Add include directories needed to use VTK. include_directories(${VTK_INCLUDE_DIRS}) to
# Add include directories needed to use VTK. include_directories(SYSTEM ${VTK_INCLUDE_DIRS}) and it seems to have squelched the warnings from VTK header files by marking them as SYSTEM libraries.
CMakeLists.txtfile? Are you using theincludecommand?INCLUDE(${VTK_USE_FILE})