[Cmake] Determining host compiler/OS from CMake
Parag Chandra
pchandra at mi-corporation.com
Fri Mar 1 09:19:00 EST 2002
Thanks a lot! I managed to solve my problem yesterday with this:
IF (WIN32)
Command
ENDIF (WIN32)
IF (UNIX)
Command
ENDIF (UNIX)
IF (CYGWIN)
Command
ENDIF (CYGWIN)
Seems all these defines are in the system already, but weren't
documented (at least I couldn't find them).
-----Original Message-----
From: William A. Hoffman [mailto:bill.hoffman at kitware.com]
Sent: Friday, March 01, 2002 9:00 AM
To: Andy Cedilnik; Parag Chandra; cmake at public.kitware.com
Subject: Re: [Cmake] Determining host compiler/OS from CMake
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