Unsupported compiler error when linking with Intel compiler

Hello,

I successfully built ITK 5.1.1 static libraries with gcc 7.4, but having an issue linking them to my application, which uses an Intel compiler.

I’m getting an “Unsupported compiler” error thrown by the generated include file itk_compiler_detection.h from this conditional (starting at line 153 in my build):

# if ITK_COMPILER_IS_GNU
# include "compilers/ITK_COMPILER_INFO_GNU_CXX.h"
# else
# error Unsupported compiler
# endif

Looking through the preceding code in that file, I’m seeing that ITK_COMPILER_IS_GNU is not set to 1 if __INTEL_COMPILER or __ICC is defined.

To confirm the source of the issue, I changed the conditional above to this:
# if ITK_COMPILER_IS_GNU || ITK_COMPILER_IS_Intel

and the “Unsupported compiler” error went away.

Since modifying a generated file isn’t a good solution, is there a bug in ITK CMake files that causes the build to generate files that don’t accommodate linking with an Intel compiler? If yes, can we resolve it?

If not, did I miss some CMake configuration setting that can be used to eliminate this issue?

Attaching my full itk_compiler_detection.h file for reference:
itk_compiler_detection.h.bak (7.8 KB)

Thanks a lot.

@hjmjohnson @phcerdan I think we already encountered this problem before, but I can’t find that discussion.

@dzenanz, I just found this thread:2 errors when trying to build Unity+MagicLeap plugin
Is that the one you’re referring to?

One suggestion in that thread is to use the same compiler for ITK and the application. At the same time, Intel compilers are supposed to be interoperable with GCC. Intel compilers define both _GNUC_ and __INTEL_COMPILER for example. Perhaps this should be accommodated in the ITK CMake logic? Meaning, the itk_compiler_detection.h should set ITK_COMPILER_IS_GNU also in addition to ITK_COMPILER_IS_Intel, if it’s an Intel compiler.

That is the simplest solution.

But I think there were some other discussions, specifically for GCC+Intel. I don’t remember whether there is a way to use that, or conclusion was to build ITK and your application using the same compiler.