Ticket #10353 (closed: fixed)

Opened 6 years ago

Last modified 5 years ago

CMake gcc version check is incorrect for SUSE linux

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: minor Milestone: Release 3.3
Component: Framework Keywords:
Cc: Blocked By:
Blocking: Tester: Pete Peterson

Description

From mailing list:

I've successfully compiled and installed Mantid from source code on a OpenSUSE 12.3 Linux system after carefully selecting and installing the necessary libraries and software and doing the following necessary adjustment.

In fact, I've found that the Build/CMake/GNUSetup.cmake script incorrectly extracts the GCC compiler version string on Linux systems. The original script fragment is:

# Get the GCC version EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS --version | cut -d \" \" -f 3 \ OUTPUT_VARIABLE _compiler_output) STRING(REGEX REPLACE ".*([0-9]
.[0-9]
.[0-9]).*" "
1" \ GCC_COMPILER_VERSION ${_compiler_output}) MESSAGE(STATUS "gcc version: ${GCC_COMPILER_VERSION}")

But the typical output of a 'gcc --version' command is a 4-row string, like the following:

gcc (SUSE Linux) 4.7.2 20130108 [gcc-4_7-branch revision 195012] Copyright (C) 2012 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.

and by applying the 'cut -d " " -f 3' filter this ends up with a wrong-syntax CMakeCache.txt file, such as:

... FIND_PACKAGE_MESSAGE_DETAILS_muparser:INTERNAL=[/usr/lib64/libmuparser.so][/usr/include][v()] GCC_COMPILER_VERSION:INTERNAL=Linux) 2012 free even ADVANCED property for variable: GIT_EXECUTABLE GIT_EXECUTABLE-ADVANCED:INTERNAL=1 ...

This causes errors in the compile/install process and, even when one corrects manually the error in the CMakeCache.txt file to bypass the problem, the error reappears after any cmake/make invocation.

Since we need to select the '4.7.2' string (or similar) on the first row, the following can be a good fix for the GNUSetup.cmake script:

# Get the GCC version EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS --version | head -n 1 | cut -d \"\)\" -f 2 \ | cut -d \" \" -f 2 OUTPUT_VARIABLE _compiler_output) STRING(REGEX REPLACE ".*([0-9]
.[0-9]
.[0-9]).*" "
1" \ GCC_COMPILER_VERSION ${_compiler_output}) MESSAGE(STATUS "gcc version: ${GCC_COMPILER_VERSION}")

Best regards.

Gianluca Frustagli

Change History

comment:1 Changed 6 years ago by Martyn Gigg

  • Status changed from new to assigned

comment:2 Changed 6 years ago by Martyn Gigg

  • Status changed from assigned to inprogress

comment:3 Changed 6 years ago by Martyn Gigg

Use CMake compiler version flag to set GCC_COMPILER_VERSION variable

This should work across the board rather than having to parse the output of 'gcc --version', which can be different on different platforms. Refs #10353

Changeset: 2c204b0b91d1ab316d2b59025c60794892b84881

comment:4 Changed 6 years ago by Martyn Gigg

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:5 Changed 6 years ago by Martyn Gigg

This is being verified as pull request #40.

comment:6 Changed 6 years ago by Pete Peterson

  • Status changed from verify to verifying
  • Tester set to Pete Peterson

comment:7 Changed 6 years ago by Pete Peterson

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/bugfix/10353_cmake_gcc_version'

Full changeset: 440baf71f9029b5c881cda911240a24c1b3de55c

comment:8 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 11195

Note: See TracTickets for help on using tickets.