views:

13

answers:

1

Hey there,

I do have a simple cmake project (on linux) that loads some libraries from custom places. I now would like to use the Intel compiler instead of the gnu compiler and add some if statement to my CMakeLists.txt that loads different libraries based on the type of compiler used.

So I would specify the usage of the Intel compiler via the CXX environment variable (is that correct?) at cmake configuration time. I then would need an if-statement in the line of

IF ( INTEL_IS_USED )
  BLA BLA
ELSE
  BLA BLA

What would be the easiest way to do this? Especially, is there some variable that I can query for the compiler type and what would be its value for the Intel compiler?

Cheers, Oliver

+2  A: 

You can check out the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER variables.

Something like this:

if (${CMAKE_C_COMPILER} MATCHES "icc.*$") 
  set(USING_INTEL TRUE)
endif ()
the_void