[CMake] How do you determine what compiler is being used?
Bartlett, Roscoe A
rabartl at sandia.gov
Wed Dec 3 18:13:10 EST 2008
Here is some CMake code that I wrote to determine this:
# Determine compiler version
INCLUDE(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES(
"
int main() {
#ifdef __sun
// This is the SUN!
#else
THIS IS NOT THE SUN
#endif
return 0;
}
"
Trilinos_USING_SUN_COMPILER
)
I was going to put this into a module called CheckCXXDefineExists.cmake with the function CHECK_CXX_DEFINE_EXISTS(...) that would be used like:
CHECK_CXX_DEFINE_EXISTS(__sun Trilinos_USING_SUN_COMPILER)
CMake does not appear to have a module/macro like this.
Should I define this module/function and would CMake like to have it to add to its sources?
- Ross
> -----Original Message-----
> From: Eric Noulard [mailto:eric.noulard at gmail.com]
> Sent: Wednesday, December 03, 2008 4:06 PM
> To: Bartlett, Roscoe A
> Cc: cmake at cmake.org; Pawlowski, Roger P
> Subject: Re: [CMake] How do you determine what compiler is being used?
>
> 2008/12/3 Bartlett, Roscoe A <rabartl at sandia.gov>:
> > Hello,
> >
> > How can determine what general type of compiler is being used? For
> > example, how can we determine if our project is being configured to
> > use the Sun CC compiler? In C++ code I can just check for
> the define
> > __sun but how can I get this info in my CMakeLists.txt
> file? I could
> > use try_compile(...) to figure this out but is there
> already a way to do this?
>
> There are some variables like
> CMAKE_COMPILER_IS_GNUCC
> MINGW
> MSVC
>
> but there is nothing for Sun CC
> http://www.cmake.org/Wiki/CMake_Useful_Variables
>
> You may guess it using
> CMAKE_C_COMPILER
> which contains the full path to the compiler.
>
> may be the set of recognized compilers may be enhanced using
> macro predefined by those compilers:
> http://predef.sourceforge.net/precomp.html
>
> --
> Erk
>
>
More information about the CMake
mailing list