[Cmake] Determining host compiler/OS from CMake

Parag Chandra pchandra at mi-corporation.com
Thu Feb 28 14:20:53 EST 2002


Ok, well I searched in my CmakeCache file and I see that there is a
CMAKE_CXX_COMPILER variable; that might be good enough for my purposes.
Now, how can I perform a test on that to see if it matches another
string, i.e. something like:

IF (CMAKE_CXX_COMPILER MATCHES "VC++60")
	Do one command here
ELSE (CMAKE_CXX_COMPILER MATCHES "VC++60")
	Do another command otherwise
ENDIF

I tried both {$CMAKE_CXX_COMPILER} and the way listed above, and both of
them cause Cmake to complain with parse errors. I guess if there already
exist "BORLAND", "WIN32", and "UNIX", is there also one for "CYGWIN"?

Thanks for your help.

-----Original Message-----
From: Andy Cedilnik [mailto:Andy.Cedilnik at kitware.com] 
Sent: Thursday, February 28, 2002 12:15 PM
To: Bill Hoffman; Parag Chandra; cmake at public.kitware.com
Subject: Re: [Cmake] Determining host compiler/OS from CMake

At 11:53 AM 2/28/2002 -0500, Bill Hoffman wrote:
>Short answer: No, currently there is not.
>
>>Is there a predefined Cmake variable that I can use to determine the 
>>compiler and/or the operating system that Cmake is running under? I d 
>>like Cmake to be able to set some flags via the ADD_DEFINITIONS
command 
>>using this information.

Not to want to start the flame fights, but it may be a good idea to add
some minimal support for getting compiler information in CMake.
I mean, you can always do things in your C files and determine
what compiler it is, but we could have something like:
CMAKE_CXX_COMPILER_TYPE, which would say something like
gcc,  hpux-aCC,  msvc, or bcc. This way developer could do some
tricks inside CMake versus inside source files.

There is a "hacky" way of determining certain things already. For
example you can say IF(BORLAND) for borland or IF(WIN32) IF(UNIX)
for cygwin and so on.

So, simple mechanism for describing compiler and platform:

COMPILER_TYPE=gcc
COMPILE_PLATFORM=win32
= cygwin

Comments?

                         Andy




More information about the CMake mailing list