My problem is simple : if I check the gcc version, I obtain 4.5.1, but CMake find gcc 4.5.0 :
> /usr/bin/gcc --version
gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> mkdir BUILD & cd BUILD
> cmake ..
-- The C compiler identification is GNU 4.5.0
-- The CXX compiler identification is GNU 4.5.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
Who is wrong ? CMake or Gcc ?
I use cmake 2.8.9, but I also have the bug with cmake 3.1.0.
I don't have the bug with gcc 4.7.2, 4.4.7 and 4.1.2.
The solution I found was similar to @usr1234567 that essentially CMake uses cc and c++ wherever they are off the $PATH, which is not always the same as gcc or g++.
Specifying these compilers fixes the version shown by CMake:
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ..
CMake uses /usr/bin/c++ probably this is still pointing to gcc 4.5.0. If you want to set the compiler, add -DCMAKE_CXX_COMPILER to the compiler you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With