[CMake] GCC version variable

Mike Jackson imikejackson at gmail.com
Wed Jun 18 17:06:33 EDT 2008


This is taken from a FindBoost.cmake file I had laying around. Adjust  
for your needs:

          EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
                     ARGS --version
                     OUTPUT_VARIABLE _boost_COMPILER_VERSION
                 )
                 STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\. 
[0-9] .*" "\\1\\2"
                    _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
                 SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")


-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jun 18, 2008, at 4:48 PM, Emmanuel Blot wrote:

> Is there some CMake macro to report the version of the GCC compiler  
> version?
> It seems these macros exist for the CL compiler, but I've not found  
> the matching macros for GCC.
>
> Some warnings are produced w/ GCC 4, but the matching warning shut- 
> off option only exists for GCC 4 (not for GCC3).
> I'd like to enable the -Wno-... option switch only for build built  
> with gcc 4, and do nothing with GCC 3.
>
> Thanks,
> Manu
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list