Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake gcc version check is incorrect for SUSE linux #11195

Closed
martyngigg opened this issue Oct 13, 2014 · 1 comment
Closed

CMake gcc version check is incorrect for SUSE linux #11195

martyngigg opened this issue Oct 13, 2014 · 1 comment
Assignees
Labels
Framework Issues and pull requests related to components in the Framework Low Priority Things that you don't ever want to be done.
Milestone

Comments

@martyngigg
Copy link
Member

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

@martyngigg
Copy link
Member Author

This issue was originally trac ticket 10353

@martyngigg martyngigg added Low Priority Things that you don't ever want to be done. Framework Issues and pull requests related to components in the Framework labels Jun 3, 2015
@martyngigg martyngigg self-assigned this Jun 3, 2015
@martyngigg martyngigg added this to the Release 3.3 milestone Jun 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues and pull requests related to components in the Framework Low Priority Things that you don't ever want to be done.
Projects
None yet
Development

No branches or pull requests

1 participant