From dbb46bcad8c675e3ce391d227750ee825907202d Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 15 Feb 2024 13:47:49 +0100 Subject: [PATCH] CMake: Fix include path returned by find_pip_package SetupShibokenAndPyside macro checks module include path and eventually decides to disable respective module in case its include directory is missing. Make this process more straightforward by testing directory existence; "Location: " string is 10 not 9 characters long and leading whitespace makes testing for directory name fail. While there, rename variables to respect that find_pip_package returns only single include and library path. --- .../SetupShibokenAndPyside.cmake | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake index 14e896c083..0569c1fde9 100644 --- a/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake +++ b/cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake @@ -48,9 +48,8 @@ macro(SetupShibokenAndPyside) if(NOT SHIBOKEN_INCLUDE_DIR) find_pip_package(Shiboken${SHIBOKEN_MAJOR_VERSION}) if (Shiboken${SHIBOKEN_MAJOR_VERSION}_FOUND) - set(SHIBOKEN_INCLUDE_DIR ${Shiboken${SHIBOKEN_MAJOR_VERSION}_INCLUDE_DIRS}) - set(SHIBOKEN_LIBRARY ${Shiboken${SHIBOKEN_MAJOR_VERSION}_LIBRARIES}) - set(SHIBOKEN_FOUND TRUE) + set(SHIBOKEN_INCLUDE_DIR ${Shiboken${SHIBOKEN_MAJOR_VERSION}_INCLUDE_DIR}) + set(SHIBOKEN_LIBRARY ${Shiboken${SHIBOKEN_MAJOR_VERSION}_LIBRARY}) endif() endif() @@ -63,9 +62,8 @@ macro(SetupShibokenAndPyside) if(NOT PYSIDE_INCLUDE_DIR) find_pip_package(PySide${PYSIDE_MAJOR_VERSION}) if (PySide${PYSIDE_MAJOR_VERSION}_FOUND) - set(PYSIDE_INCLUDE_DIR ${PySide${PYSIDE_MAJOR_VERSION}_INCLUDE_DIRS}) - set(PYSIDE_LIBRARY ${PySide${PYSIDE_MAJOR_VERSION}_LIBRARIES}) - set(PYSIDE_FOUND TRUE) + set(PYSIDE_INCLUDE_DIR ${PySide${PYSIDE_MAJOR_VERSION}_INCLUDE_DIR}) + set(PYSIDE_LIBRARY ${PySide${PYSIDE_MAJOR_VERSION}_LIBRARY}) endif() endif() @@ -186,15 +184,23 @@ macro(find_pip_package PACKAGE) if(${NAME_STRING_LOCATION} EQUAL 0) STRING(SUBSTRING "${LINE}" 6 -1 PIP_PACKAGE_NAME) elseif(${LOCATION_STRING_LOCATION} EQUAL 0) - STRING(SUBSTRING "${LINE}" 9 -1 PIP_PACKAGE_LOCATION) + STRING(SUBSTRING "${LINE}" 10 -1 PIP_PACKAGE_LOCATION) endif() endforeach() + message(STATUS "Found pip-installed ${PACKAGE} in ${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}") file(TO_NATIVE_PATH "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/include" INCLUDE_DIR) file(TO_NATIVE_PATH "${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}/lib" LIBRARY) - set(${PACKAGE}_INCLUDE_DIRS ${INCLUDE_DIR}) - set(${PACKAGE}_LIBRARIES ${LIBRARY}) + if(EXISTS ${INCLUDE_DIR}) + set(${PACKAGE}_INCLUDE_DIR ${INCLUDE_DIR}) + else() + message(STATUS "${PACKAGE} include directory '${INCLUDE_DIR}' does not exist") + endif() + if(EXISTS ${LIBRARY}) + set(${PACKAGE}_LIBRARY ${LIBRARY}) + else() + message(STATUS "${PACKAGE} library directory '${LIBRARY}' does not exist") + endif() set(${PACKAGE}_FOUND TRUE) - message(STATUS "Found pip-installed ${PACKAGE} in ${PIP_PACKAGE_LOCATION}/${PIP_PACKAGE_NAME}") endif() endmacro()