[CMake] Intel compilers

Rolf Eike Beer eike at sf-mail.de
Fri May 11 03:01:22 EDT 2012


> Hi,
>
> I have just started using CMake for my projects and have some problems
> getting it do exactly the things I want. So these are couple of questions
> I
> have:
>
> 1) How can I change the compiler from GNU g++ to my preferred compiler, in
> this case intel's icc? I have tried CC=icc; ccmake ../ but that again
> defaults to g++ and picks up wrong compiler flags

See the other mail. But this only works for the first time when you
compile in a given build directory, i.e. it is not possible to switch the
compiler on an already configured project.

> 2) When I use the -ipo flag for icc, intel compiler complains that there
> are unresolved references whereas if I omit that, or just use g++, I don't
> have linking problems. Does the order of compilation (except main) matter
> when using target_link_libraries?

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.

The order you pass things to target_link_libraries() doesn't matter as
CMake will reorder them to resolve all dependencies it knows of. Therefore
you need to target_link_libraries() also the static libraries together.
Even if that doesn't really link anything it will tell CMake about the
dependencies when later really linking.

> 3) How can I change from creating static libraries to just simply create
> object files and link to them?

In CMake 2.8.8 there are OBJECT libraries, this may be what you want.

Eike


More information about the CMake mailing list