From: abn Date: Mon, 7 Nov 2016 14:47:58 +0000 (+0100) Subject: Bug fix: better Python version checking X-Git-Tag: V8_2_0b1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3b7430b7a656b757f858e582605ea80ee9c1d36c;p=tools%2Fconfiguration.git Bug fix: better Python version checking On Ubuntu, libs might be marked as "2.7.12+" and interp as "2.7.12" ... annoying. --- diff --git a/cmake/FindSalomePythonLibs.cmake b/cmake/FindSalomePythonLibs.cmake index 36473f2..3ad5367 100644 --- a/cmake/FindSalomePythonLibs.cmake +++ b/cmake/FindSalomePythonLibs.cmake @@ -48,7 +48,9 @@ ENDIF() ## Specifics -- check matching version with Interpreter if already detected: IF (SALOMEPYTHONLIBS_FOUND AND SALOMEPYTHONINTERP_FOUND) # Now ensure versions are matching - IF("${PYTHONLIBS_VERSION_STRING}" STREQUAL "${PYTHON_VERSION_STRING}") + SALOME_EXTRACT_VERSION(${PYTHONLIBS_VERSION_STRING} maj_lib min_lib patch_lib) + SALOME_EXTRACT_VERSION(${PYTHON_VERSION_STRING} maj_inter min_inter patch_inter) + IF("${maj_lib}.${min_lib}.${patch_lib}" STREQUAL "${maj_inter}.${min_inter}.${patch_inter}") MESSAGE(STATUS "Python libs and interpreter versions are matching: ${PYTHONLIBS_VERSION_STRING}") ELSE() MESSAGE(FATAL_ERROR "Python libs and interpreter versions are NOT matching: ${PYTHONLIBS_VERSION_STRING} vs ${PYTHON_VERSION_STRING}") diff --git a/cmake/SalomeMacros.cmake b/cmake/SalomeMacros.cmake index 2581731..3daf597 100644 --- a/cmake/SalomeMacros.cmake +++ b/cmake/SalomeMacros.cmake @@ -955,3 +955,21 @@ MACRO(SALOME_CONFIGURE_PREPARE) ENDIF() ENDFOREACH() ENDMACRO(SALOME_CONFIGURE_PREPARE) + +####################################################################### +# +# From a version string like "2.7.12+" extract the major, minor and patch number +# taking ONLY the numerical part. +# This macro was created to treat Ubuntu Python version number where the libs are +# version 2.7.12+ and the interp is 2.7.12 ... +# +MACRO(SALOME_EXTRACT_VERSION version_string major minor patch) + IF(${version_string} MATCHES "[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.[0-9]+[^0-9]*") + STRING(REGEX REPLACE "^([0-9]+)[^0-9]*\\.[0-9]+[^0-9]*\\.[0-9]+[^0-9]*" "\\1" ${major} "${version_string}") + STRING(REGEX REPLACE "^[0-9]+[^0-9]*\\.([0-9]+)[^0-9]*\\.[0-9]+[^0-9]*" "\\1" ${minor} "${version_string}") + STRING(REGEX REPLACE "^[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.([0-9]+)[^0-9]*" "\\1" ${patch} "${version_string}") + ELSE() + MESSAGE("MACRO(SALOME_EXTRACT_VERSION ${version_string} ${major} ${minor} ${patch}") + MESSAGE(FATAL_ERROR "Problem parsing version string, I can't parse it properly.") + ENDIF() +ENDMACRO(SALOME_EXTRACT_VERSION)