[CMake] GCC version variable

Miguel A. Figueroa-Villanueva miguelf at ieee.org
Thu Jun 19 08:13:16 EDT 2008


On Thu, Jun 19, 2008 at 5:28 AM, Martin Apel wrote:
> Mike Jackson wrote:
>>
>> 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}")
>>
>>
> Don't use this regular expression to find out the GCC version!
> I filed a bug report for FindBoost.cmake
> (http://public.kitware.com/Bug/view.php?id=7097) some weeks ago, that this
> doesn't work reliably.
> I built GCC myself with a suffix of -32, which confuses the regular
> expression above. As a workaround I modified my local FindBoost.cmake to use
>  STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9].*" "\\1\\2"
>  _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
> Note the blank after the initial ".*"!

If it is only for gcc, why not use "execute_process" ("exec_program"
is deprecated) and call "gcc -dumpversion" ?

Hope this helps,
--Miguel


More information about the CMake mailing list