[CMake] Intel compilers

Mohammad Mirzadeh mirzadeh at gmail.com
Fri May 11 17:12:49 EDT 2012


> You generally need to set CC, CXX, LD, and AR.  I found that in some cases
> even that didn't work.  I use this:

> option(INTEL_CC "Use the Intel compiler." OFF)

> if (INTEL_CC)
> find_program(CMAKE_C_COMPILER NAMES icc)
> find_program(CMAKE_CXX_COMPILER NAMES icpc)
> find_program(CMAKE_AR NAMES xiar)
> find_program(CMAKE_LINKER NAMES xild)

> if (CMAKE_C_COMPILER MATCHES CMAKE_C_COMPILER-NOTFOUND OR
>     CMAKE_CXX_COMPILER MATCHES CMAKE_CXX_COMPILER-NOTFOUND OR
>     CMAKE_AR MATCHES CMAKE_AR-NOTFOUND OR
>     CMAKE_LINKER MATCHES CMAKE_LINKER-NOTFOUND)
>   message(FATAL_ERROR "Cannot find Intel compiler.  You may need to run
`. /opt/intel/bin/compilervars.sh intel64'")
> endif ()
> endif (INTEL_CC)

When I run ccmake -DINTEL_CC:BOOL=ON path/to/CMakeLists.txt, It does not
pick up intel compilers and I'm stuck with gcc. If I do CC=icc CXX=icpc
ccmake -DINTEL_CC:BOOL=ON path/to/CMakeLists.txt it can correctly find all
the libraries and prints:

CMake Warning at CMakeLists.txt:10 (ADD_EXECUTABLE):
   Cannot generate a safe linker search path for target cmTryCompileExec
   because files in some directories may conflict with libraries in implicit
   directories:

     link library [libimf.so] in /opt/apps/intel/10.1/cc/lib may be hidden
by files in:
       /opt/apps/intel/10.1/fc/lib
     link library [libsvml.so] in /opt/apps/intel/10.1/cc/lib may be hidden
by files in:
       /opt/apps/intel/10.1/fc/lib
     link library [libipgo.a] in /opt/apps/intel/10.1/cc/lib may be hidden
by files in:
       /opt/apps/intel/10.1/fc/lib
     link library [libirc.so] in /opt/apps/intel/10.1/cc/lib may be hidden
by files in:
       /opt/apps/intel/10.1/fc/lib
     link library [libirc_s.a] in /opt/apps/intel/10.1/cc/lib may be hidden
by files in:
       /opt/apps/intel/10.1/fc/lib

   Some of these libraries may not be found correctly.

Do I need to fix my LD_LIBRARY_PATH? right now it seems echo
$LD_LIBRARY_PATH says: /opt/apps/intel/10.1/cc/lib is in path (along with
other stuff of course).

> What references is it missing?  I'm willing to bet it's having trouble
> finding the intel libraries, maybe irc or imf.  Make sure you have sourced
> the compiler vars script before running cmake.  Maybe if you tell me what
> references it can't find I can help better.

Its not system libraries its missing, it seems to be some of my own.
Problem is when I turn on ipo, apparently compiler requires all the other
symbols from all the functions that are called when building each library.
Normally I do not need them until linking to my executable so when I omit
ipo, there is no issue. Also, if if I use ip, which does the same sort of
optimization but restricts to the current file, I do not get linking issues.

> I guess you have some static libraries that need symbols from each other
> and you have not added all necessary target_link_libraries() calls.
> Without this the linking order is obviously not right.

Yes that seems to be the case. So normally, without ipo, there is no
linking problems since all the actual linking happens when building
the executable at which point I link to all required libraries. Question
is, when you are building a static libraries, do you require all the
linking symbols at that point or you could relax until linking the
executable? This brings us to my last question. Is this fundamentally
different when working object files? I do not think you would need symbols
when working with object files until you initiate the linking. That's why I
asked if I could bypass the static libraries and just make the objects
instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120511/fe06c1f1/attachment.htm>


More information about the CMake mailing list