[CMake] mixed compilation with two compilers

David Cole david.cole at kitware.com
Tue Feb 15 11:31:49 EST 2011


You should use ExternalProject, and possibly wrapper scripts to set
environment variables for the projects that need to use the different
compiler. (CC, CXX, FC env vars should be set during the configure stage, or
you can pass them in as -D args to cmake)

CMake does not support changing the compiler in a sub-portion of the build
tree.


On Tue, Feb 15, 2011 at 11:23 AM, Dominik Szczerba <dominik at itis.ethz.ch>wrote:

> I need to compile a few subprojects (each is a subfolder with one
> library and a corresponding CMakeLists.txt) with the Intel compiler
> while the rest of the libraries (organized the same way), including
> the executable, using the system compiler (GNU on linux, VC on
> Windows). I tried two solutions to no avail:
>
> 1) In the subfolder's CMakeLists.txt do like:
>
>        SET(CMAKE_CXX_COMPILER ${INTEL_CXX_COMPILER})
>        SET(CMAKE_CXX_FLAGS_DEBUG ${INTEL_CXX_FLAGS_DEBUG})
>
> While this substitutes the CMAKE_CXX* variables correctly with
> INTEL_CXX* ones (confirmed by MESSAGE) the actual compilation still
> takes place using parent CMAKE_CXX_* variables. This is very
> surprising as many other CMake commands respect the subfolder scope.
>
> 2) Properties. There is a way to have ADDITIONAL compile flags, but
> not CUSTOM. There seems to be no property for the compiler itself.
>
> The compilation has to be mixed, and no post-processing (like some
> converting scripts) are allowed. Is this possible or this is a dead
> end?
>
> Best regards,
> Dominik
> _______________________________________________
> 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/20110215/738e531e/attachment-0001.htm>


More information about the CMake mailing list