From fda4b4e3c2281cb332b264f52c3ec96af895a197 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Nov 2017 06:12:26 -0500 Subject: [PATCH] CMake: improve searching for PythonQt - don't log when libs not found - log that it's the Python libraries version (not Python itself) - fix RE that was getting the wrong results for maj.min --- CMakeModules/FindPythonQt.cmake | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeModules/FindPythonQt.cmake b/CMakeModules/FindPythonQt.cmake index 0d886902d..8de40853f 100644 --- a/CMakeModules/FindPythonQt.cmake +++ b/CMakeModules/FindPythonQt.cmake @@ -9,12 +9,19 @@ if(NOT PYTHONLIBS_FOUND) message(FATAL_ERROR "error: Python is required to build PythonQt") endif() +# Cut X.Y[.Z] down to just X.Y string(REGEX REPLACE "^([0-9][0-9]*)\.([0-9][0-9]*)" - "\\1" - PYTHONLIBS_MAJMIN + "\\1.\\2@" + _PYTHONLIBS_MAJMIN ${PYTHONLIBS_VERSION_STRING} ) +string(REGEX REPLACE + "@.*" + "" + PYTHONLIBS_MAJMIN + ${_PYTHONLIBS_MAJMIN} +) if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}") find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.") @@ -30,7 +37,7 @@ find_path(PYTHONQT_INCLUDE_DIR PythonQt.h DOC "Path to the PythonQt include directory") if ( NOT PythonQt_FIND_QUIETLY ) - message( STATUS "Searching for PythonQt (Python ${PYTHONLIBS_MAJMIN}) .." ) + message( STATUS "Searching for PythonQt (PythonLibs ${PYTHONLIBS_MAJMIN}) .." ) if ( PYTHONQT_INCLUDE_DIR ) message( STATUS " .. found include ${PYTHONQT_INCLUDE_DIR}" ) endif() @@ -99,8 +106,12 @@ if(PYTHONQT_QTALL_LIBRARY_DEBUG) endif() if ( NOT PythonQt_FIND_QUIETLY ) - message( STATUS " .. found library ${PYTHONQT_LIBRARY}" ) - message( STATUS " .. found qtall ${PYTHONQT_QTALL_LIBRARY}" ) + if ( PYTHONQT_LIBRARY ) + message( STATUS " .. found library ${PYTHONQT_LIBRARY}" ) + endif() + if ( PYTHONQT_QTALL_LIBRARY ) + message( STATUS " .. found qtall ${PYTHONQT_QTALL_LIBRARY}" ) + endif() endif()