[CMake] Newbie question - how to use multiple C++ compilers?

William A. Hoffman billlist at nycap.rr.com
Fri Jun 2 17:42:29 EDT 2006


At 09:06 PM 6/1/2006, Bennett Smith wrote:
>Hello,
>
>I am trying to convert our current home-brew build system to use
>cmake.  One issue we have is that some libraries are built using
>Visual C++ 7.1 and other libraries and executables are built using
>VIsual C++ 6.0. I would like to somehow indicate in each subdirectory
>which version of the C++ compiler is required, perhaps in the
>CMakeLists.txt file.  Is this possible?

Anything is possible.  :)  It is out of the ordinary.  There is no
way to have a project built with two different compilers.   Obviously,
you could not use the MS IDE to do this.   In CMake 2.4, you can
test for the version of the MS compiler;

The following variables will be set depending on the MS compiler version:
MSVC60, MSVC70, MSVC71, MSVC80

So, you could do this at the top of the 6.0 project:
if(NOT MSVC60) 
  message(FATAL_ERROR, "This project requires MSV60")
endif(NOT MSVC60)

The user would have to run cmake once for the 6.0 stuff, and
once for the 7.1 stuff.   To get around that you could use
ctest --build-and-test or try_compile to build one as a subproject
of the other.

-Bill





More information about the CMake mailing list