3

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?

3
  • 1
    how do You "include" the CMakeLists.txt file? Are you using the include command? Commented Apr 27, 2014 at 11:15
  • 1
    this is the way that external libraries that use cmake on their structures (such as VTK, ITK) may be included:INCLUDE(${VTK_USE_FILE}) Commented Apr 28, 2014 at 11:41
  • 1
    for a non cmakelist library such as Qt I can load it in my CmakeList using the directive INCLUDE_DIRECTORIES using the parameter SYSTEM that indicates that those headers are from the system (this way the compiler does not verify warnings from these "external" headers) Commented Apr 28, 2014 at 11:44

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

You can insert include_directories(SYSTEM ${VTK_INCLUDE_DIRS}) instructions right after the find_package instructions.

find_package(VTK REQUIRED) include_directories(SYSTEM ${VTK_INCLUDE_DIRS}) include(${VTK_USE_FILE}) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.