Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMAKE_CXX_COMPILER_VERSION is pointing to the old GCC version

Tags:

c++

gcc

cmake

I have upgraded my GCC using:

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-8 g++-8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 70 --slave /usr/bin/g++ g++ /usr/bin/g++-8

Running any of these commands:

$ gcc --version
$ g++ --version
$ c++ --version
$ /usr/bin/gcc --version
$ /usr/bin/g++ --version
$ /usr/bin/c++ --version

would show (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0 confirming that version 8.1 has been installed.

When running ./configure on cmake-3.12.1 I downloaded from its website I get:

-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0

However when trying to make my actual project:

CMake Error at CMakeLists.txt:24 (message):
  GCC version must be at least 7.1! 5.4.0

This is my CMakeLists.txt:

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    # require at least gcc 7.1
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1)
        message(FATAL_ERROR "GCC version must be at least 7.1!  " ${CMAKE_CXX_COMPILER_VERSION})
    endif()
endif()
like image 523
d9ngle Avatar asked Sep 05 '18 08:09

d9ngle


People also ask

Is CMake using GCC?

Usually under Linux, one uses CMakeMakeIn December 2006, Sun DevPro Make was made open source as part of the efforts to open-source Solaris. dmake or Distributed Make that came with Sun Solaris Studio as its default Make, but not the default one on the Solaris Operating System (SunOS).https://en.wikipedia.org › wiki › Make_(software)Make (software) - Wikipedia to generate a GNU make file which then uses gcc or g++ to compile the source file and to create the executable.

How do I specify GCC?

Specify the installation directory for the executables called by users (such as gcc and g++ ). The default is exec-prefix /bin . Specify the installation directory for object code libraries and internal data files of GCC. The default is exec-prefix /lib .


1 Answers

As Shawn, Tsyvarev and hellow have mentioned in the comments, this problem is caused by CMake cache file which was located inside /build/. Deleting the file solved the issue.

like image 71
d9ngle Avatar answered Sep 18 '22 18:09

d9ngle