From 32c1565867b5845472e235ae3492eee70f31ca8b Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 7 Mar 2018 16:17:36 +0100
Subject: [PATCH] Fix CMakeLists.txt regarding PythonQt.

---
 CMakeLists.txt | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc333a9..81ef667 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,8 +80,19 @@ IF(NOT CLIENT_ONLY)
     SET(PKG_CONFIG_EXTRA "qtversion=${Qt5Core_VERSION}")
   ENDIF(USE_QT4)
 
-  FIND_PACKAGE(PythonQt COMPONENTS QtAll)
-  SET(GEPETTO_GUI_HAS_PYTHONQT (${PythonQt_FOUND} AND ${PythonQt_QtAll_FOUND}) CACHE BOOL "Use PythonQt dependency")
+  # If GEPETTO_GUI_HAS_PYTHONQT is set to TRUE, then PythonQt is required.
+  IF(DEFINED GEPETTO_GUI_HAS_PYTHONQT AND GEPETTO_GUI_HAS_PYTHONQT)
+    FIND_PACKAGE(PythonQt REQUIRED COMPONENTS QtAll)
+  ELSE()
+    FIND_PACKAGE(PythonQt COMPONENTS QtAll)
+  ENDIF()
+  # Declare option GEPETTO_GUI_HAS_PYTHONQT
+  # If GEPETTO_GUI_HAS_PYTHONQT was defined, this does not change its value.
+  IF (PythonQt_FOUND AND PythonQt_QtAll_FOUND)
+    SET(GEPETTO_GUI_HAS_PYTHONQT TRUE CACHE BOOL "Use PythonQt dependency")
+  ELSE()
+    SET(GEPETTO_GUI_HAS_PYTHONQT FALSE CACHE BOOL "Use PythonQt dependency")
+  ENDIF()
 
   PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
 
-- 
GitLab