[cmake-developers] CheckGNUCompilerVersion

Michael Wild themiwi at gmail.com
Thu Apr 15 14:50:57 EDT 2010


On 15. Apr, 2010, at 20:27 , Andreas Schneider wrote:

> Hi,
> 
> I've created a module to check for the gnu compiler version.
> 
> Example:                                                                                                                                                            
> check_gnu_compiler_version("4.5.0" HAVE_GNU_COMPILER_VERSION)                                                                                                       
> 
> if (HAVE_GNU_COMPILER_VERSION)                                                                                                                                      
>    message(STATUS "GNU compiler version found")                                                                                                                     
> endif (HAVE_GNU_COMPILER_VERSION)
> 
> I just wanted to get some opinions about it. Maybe someone has some idea for 
> improvement.
> 
> Cheers,
> 
> 	-- andreas

Hi

I haven't tested it, but gave it a cursory glance. A few things:

- I'd name the second argument something with VAR in it to indicate that it's a variable name that is required. Also, you don't need to prefix variables inside a function, they are local in scope.

- First line in the function is missing a $ in the variable-reference. It should read:
  set(${_REQUIRED_VERSION_FOUND} FALSE PARENT_SCOPE)

- You don't have to check the compiler ID, there's the CMAKE_COMPILER_IS_GNUC variable.

- It would be nice if one could also check for the CXX compiler, perhaps as a first argument?

Michael


More information about the cmake-developers mailing list