[Cmake] Determining host compiler/OS from CMake
William A. Hoffman
bill.hoffman at kitware.com
Fri Mar 1 09:00:13 EST 2002
I have added some new variables, and found some old ones.
The following variables are now available (variables marked as **New will
be in cmake 1.4 or the current cvs,
the others have been around for a while.):
CMAKE_COMPILER_IS_GNUCXX - a boolean telling you if the compiler is gnu
CMAKE_SYSTEM - Win32, or the result of uname **New
CMAKE_CXX_COMPILER - the name of the command line compiler tool (cl, g++,
CC, aCC, etc)
CMAKE_BUILD_TOOL - the tool that cmake is generating to, make, nmake,
borlandmake, msdev, devenv **New
Here is a sample list file:
IF( CMAKE_COMPILER_IS_GNUCXX )
MESSAGE("Compiler is gnu")
ELSE( CMAKE_COMPILER_IS_GNUCXX)
MESSAGE("Compiler is not gnu")
ENDIF( CMAKE_COMPILER_IS_GNUCXX)
MESSAGE(" system " ${CMAKE_SYSTEM}
" compiler " ${CMAKE_CXX_COMPILER}
" build tool " ${CMAKE_BUILD_TOOL}
)
Here is the output on cygwin:
Compiler is gnu
system CYGWIN_NT-5.1-1.3.9(0.51/3/2) compiler c++ build tool make
-Bill
At 12:14 PM 2/28/2002 -0500, Andy Cedilnik wrote:
>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
>
>_______________________________________________
>Cmake mailing list
>Cmake at public.kitware.com
>http://public.kitware.com/mailman/listinfo/cmake
More information about the CMake
mailing list