[CMake] How to use CMake with icc via configuration options when needing interprocedural optimization?

Yuri Timenkov yuri at timenkov.ru
Wed Feb 8 22:21:45 EST 2012


I think this could work, but if compiler is altered before project() call
(but I didn't check this and suggest set variable only if it's not already
set). Specifying only one variable  in command line looks more
user-friendly and robust than several ones.
Anther option is using initial cache.

Regards,
Yuri

On Wed, Feb 8, 2012 at 12:59 AM, Alexander Neundorf <a.neundorf-work at gmx.net
> wrote:

> Hi Janitor,
>
> On Tuesday 07 February 2012, janitor 048 wrote:
> > Hello,
> >
> > this is a question I recently asked on stackoverflow (
> >
> http://stackoverflow.com/questions/9129233/recommended-ways-to-use-cmake-wi
> > th-icc-via-configuration-options) but that has not received any response
> > since then. Maybe this mailing list is a better place to ask... Here goes
> >
> > I would like to use the Intel compiler icc (or icpc) with a CMake-based
> > project (on Linux for what it's worth). I can of course export the CXX
> > variable when calling cmake, e.g. like
> >
> > CXX=icpc cmake ../
> >
> > and this works fine. I would however like to make this choice available
> via
> > a custom option. For this I parse custom option, e.g.
> >
> > cmake -DMY_COMPILER_OPTION=Intel ..
> >
> > as
> >
> > IF (MY_COMPILER_OPTION STREQUAL "Intel")
> >   MESSAGE(STATUS "** Compiling with Intel settings **")
> >   SET(CMAKE_CXX_COMPILER "icpc")
> >   SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -w")
> >   SET(CMAKE_CXX_FLAGS_DEBUG "-g")
> > ENDIF ()
>
> Don't do that, this is too late in the initialization process.
> The recommended way is to set the CXX environment variable. This is only
> necessary during the initial cmake run, afterwards this is stored in the
> cmake
> cmake cache.
> It should also work to preset the compiler variables:
> cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc ....
>
> (I didn't check, but it should work).
>
> Alex
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120209/1d7e014e/attachment.htm>


More information about the CMake mailing list