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.<br>
Anther option is using initial cache.<br><br>Regards,<br>Yuri<br><br><div class="gmail_quote">On Wed, Feb 8, 2012 at 12:59 AM, Alexander Neundorf <span dir="ltr"><<a href="mailto:a.neundorf-work@gmx.net">a.neundorf-work@gmx.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Janitor,<br>
<div class="im"><br>
On Tuesday 07 February 2012, janitor 048 wrote:<br>
> Hello,<br>
><br>
> this is a question I recently asked on stackoverflow (<br>
> <a href="http://stackoverflow.com/questions/9129233/recommended-ways-to-use-cmake-wi" target="_blank">http://stackoverflow.com/questions/9129233/recommended-ways-to-use-cmake-wi</a><br>
> th-icc-via-configuration-options) but that has not received any response<br>
> since then. Maybe this mailing list is a better place to ask... Here goes<br>
><br>
> I would like to use the Intel compiler icc (or icpc) with a CMake-based<br>
> project (on Linux for what it's worth). I can of course export the CXX<br>
> variable when calling cmake, e.g. like<br>
><br>
> CXX=icpc cmake ../<br>
><br>
> and this works fine. I would however like to make this choice available via<br>
> a custom option. For this I parse custom option, e.g.<br>
><br>
> cmake -DMY_COMPILER_OPTION=Intel ..<br>
><br>
> as<br>
><br>
> IF (MY_COMPILER_OPTION STREQUAL "Intel")<br>
> MESSAGE(STATUS "** Compiling with Intel settings **")<br>
> SET(CMAKE_CXX_COMPILER "icpc")<br>
> SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -w")<br>
> SET(CMAKE_CXX_FLAGS_DEBUG "-g")<br>
> ENDIF ()<br>
<br>
</div>Don't do that, this is too late in the initialization process.<br>
The recommended way is to set the CXX environment variable. This is only<br>
necessary during the initial cmake run, afterwards this is stored in the cmake<br>
cmake cache.<br>
It should also work to preset the compiler variables:<br>
cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc ....<br>
<br>
(I didn't check, but it should work).<br>
<br>
Alex<br>
<div class="HOEnZb"><div class="h5">--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br>