Marking ITK includes as SYSTEM

Hello,

I have recently discovered the SYSTEM flag for include_directories() (https://cmake.org/cmake/help/v3.0/command/include_directories.html). I’ve added this to my main CMake file for all external libraries that use include_directories so that I can enable -Wall -Wpedantic -Wextra and get warnings about my code, but not worry about external libraries.

However, I can’t see how to do this for ITK, because for ITK I have include( $ITK_USE_FILE ) instead of include_directories. Sadly, ITK does throw up a lot of warnings with -Wpedantic, e.g.:

../External/ITK/Modules/Core/Common/include/itkMath.h:204:40: warning: extra ˜;€™ [-Wpedantic]
 itkTemplateFloatingToIntegerMacro(Ceil);

This is with v4.13.0 checked-out, I haven’t had a chance to move to ITK 5 yet.

@spinicist I don’t think I can help, but I’m just wondering:

  1. Does the CMake SYSTEM flag translate to -system, in your makefiles? https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#Directory-Options

  2. Do you do #include "file" or #include < file >, when you #include an ITK header file? It might be that #include < file > works best, for the compiler to recognize the ITK headers as system headers.

Anyway, I hope that someone else can help you any further!

Thanks @Niels_Dekker

  1. Yes, I think this is what SYSTEM does.
  2. I hadn’t thought about “” versus <>. To be honest I am a bit sloppy about which I use, and I thought that these days there is little difference between them (it doesn’t seem to matter which I use, the compiler finds the right files)

I may be wrong on both points if others wish to enlighten me!