From 66db0f0a03af640a24e6457e3a63850e9d8e642a Mon Sep 17 00:00:00 2001
From: Christoph Moench-Tegeder <cmt@burggraben.net>
Date: Sun, 16 Jun 2019 21:17:46 +0200
Subject: [PATCH] fix detection of recent versions of PySide2

sometime between releases 5.6 and 5.12, the PySide2 project
reorganized their cmake files and the variables exported by
those files. In order to enable building FreeCAD with the newer
PySide2 (and Shiboken2 etc) packages with minimal changes, this
leaves the old PySide2 detection intact and tries using the
cmake properties used by the newer PySide2 releases. As a bonus,
cmake now reports an error, if PySide2 or Shiboken2 are not
found.
---
 CMakeLists.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index acd65efbe..dbae6406d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1063,6 +1063,13 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
             endif()
         endif()
 
+        # pyside2 changed it's cmake files, this is the dance we have
+        # to dance to be compatible with the old and the new versions
+        if(SHIBOKEN_PYTHON_INCLUDE_DIRS AND NOT SHIBOKEN_INCLUDE_DIR)
+          get_property(SHIBOKEN_INCLUDE_DIR TARGET Shiboken2::libshiboken PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+            get_property(SHIBOKEN_LIBRARY TARGET Shiboken2::libshiboken PROPERTY IMPORTED_LOCATION_RELEASE)
+        endif(SHIBOKEN_PYTHON_INCLUDE_DIRS AND NOT SHIBOKEN_INCLUDE_DIR)
+
         if(NOT SHIBOKEN_INCLUDE_DIR)
             message("====================\n"
                     "shiboken2 not found.\n"
@@ -1070,6 +1077,14 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
         endif(NOT SHIBOKEN_INCLUDE_DIR)
 
         find_package(PySide2 QUIET)# REQUIRED
+
+        # pyside2 changed it's cmake files, this is the dance we have
+        # to dance to be compatible with the old and the new versions
+        if(NOT PYSIDE_INCLUDE_DIR)
+          get_property(PYSIDE_INCLUDE_DIR TARGET PySide2::pyside2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+          get_property(PYSIDE_LIBRARY TARGET PySide2::pyside2 PROPERTY IMPORTED_LOCATION_RELEASE)
+        endif(NOT PYSIDE_INCLUDE_DIR)
+
         if(NOT PYSIDE_INCLUDE_DIR)
             message("==================\n"
                     "PySide2 not found.\n"
-- 
2.22.0

