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