From 3913645dc98da104596284dbe4d14d87424842a9 Mon Sep 17 00:00:00 2001
From: vahrenkamp <vahrenkamp@042f3d55-54a8-47e9-b7fb-15903f145c44>
Date: Sat, 29 Aug 2015 12:01:00 +0000
Subject: [PATCH] Added qhull-external option Renamed SceneViewer to
 SimoxSceneViewer Version 2.3.9

git-svn-id: http://svn.code.sf.net/p/simox/code/trunk@860 042f3d55-54a8-47e9-b7fb-15903f145c44
---
 CMakeLists.txt                                |  4 +-
 CMakeModules/FindQHULL.cmake                  | 47 +++++++++++++++++++
 GraspPlanning/CMakeLists.txt                  | 14 ++++--
 .../examples/SceneViewer/CMakeLists.txt       |  2 +-
 config.cmake                                  |  2 +-
 5 files changed, 63 insertions(+), 6 deletions(-)
 create mode 100644 CMakeModules/FindQHULL.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22122c964..19132982e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,9 @@ endif()
 if (Simox_BUILD_GraspStudio)
     add_subdirectory(GraspPlanning)
     list(APPEND SIMOX_EXPORT_TARGET_LIST GraspStudio)
-    list(APPEND SIMOX_EXPORT_TARGET_LIST simox-qhull)
+    if (BUILD_qhull)
+        list(APPEND SIMOX_EXPORT_TARGET_LIST simox-qhull)
+    endif()
     list(APPEND SIMOX_EXPORT_TARGET_LIST powercrust)
     list (APPEND Simox_LIBRARIES GraspStudio)
 endif()
diff --git a/CMakeModules/FindQHULL.cmake b/CMakeModules/FindQHULL.cmake
new file mode 100644
index 000000000..006041367
--- /dev/null
+++ b/CMakeModules/FindQHULL.cmake
@@ -0,0 +1,47 @@
+# Searches for QHULL includes and library files
+#
+# Sets the variables
+#   QHULL_FOUND
+#   QHULL_INCLUDE_DIR
+#   QHULL_LIBRARIES
+
+SET (QHULL_FOUND FALSE)
+
+FIND_PATH (QHULL_INCLUDE_DIR qhull/qhull.h
+	/usr/include
+	/usr/local/include
+	$ENV{HOME}/local/include
+	$ENV{QHULL_PATH}/src
+	$ENV{QHULL_PATH}/include
+	$ENV{QHULL_INCLUDE_PATH}
+	)
+FIND_LIBRARY (QHULL_LIBRARY NAMES qhull	PATHS
+	/usr/lib
+	/usr/local/lib
+	$ENV{HOME}/local/lib
+	$ENV{QHULL_PATH}
+	$ENV{QHULL_LIBRARY_PATH}
+	)
+
+
+IF (QHULL_INCLUDE_DIR AND QHULL_LIBRARY)
+	SET (QHULL_FOUND TRUE)
+ENDIF (QHULL_INCLUDE_DIR AND QHULL_LIBRARY)
+
+SET(QHULL_LIBRARIES ${QHULL_LIBRARY})
+
+IF (QHULL_FOUND)
+   IF (NOT QHULL_FIND_QUIETLY)
+      MESSAGE(STATUS "Found QHULL: ${QHULL_LIBRARY}")
+   ENDIF (NOT QHULL_FIND_QUIETLY)
+ELSE (QHULL_FOUND)
+   IF (QHULL_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find QHULL")
+   ENDIF (QHULL_FIND_REQUIRED)
+ENDIF (QHULL_FOUND)
+
+MARK_AS_ADVANCED (
+	QHULL_INCLUDE_DIR
+	QHULL_LIBRARIES
+	QHULL_LIBRARY	
+	)
diff --git a/GraspPlanning/CMakeLists.txt b/GraspPlanning/CMakeLists.txt
index 47a1eb94b..0fe1d33d1 100644
--- a/GraspPlanning/CMakeLists.txt
+++ b/GraspPlanning/CMakeLists.txt
@@ -16,13 +16,20 @@ ENDMACRO(ADD_GRASPSTUDIO_TEST)
 
 
 ########### QHULL #################
-OPTION(BUILD_qhull "if on builds qhull external library" ON)
+OPTION(BUILD_qhull "if on builds qhull external library" OFF)
 IF(BUILD_qhull)
 	ADD_SUBDIRECTORY(ExternalDependencies/qhull-2003.1)
-ENDIF(BUILD_qhull)
+    set(QHULL_LIBRARIES simox-qhull)
+else()
+    find_package(QHULL REQUIRED)
+    include_directories(${QHULL_INCLUDE_DIRS})
+endif()
 ########### END QHULL #################
 
 
+
+
+
 ########### POWERCRUST #################
 OPTION(BUILD_powercrust "if on builds powercrust external library" ON)
 IF(BUILD_powercrust)
@@ -126,7 +133,8 @@ ADD_DEFINITIONS(${Simox_EXTERNAL_LIBRARY_FLAGS})
 
 
 ADD_LIBRARY (GraspStudio SHARED ${SOURCES} ${INCLUDES})
-TARGET_LINK_LIBRARIES (GraspStudio Saba VirtualRobot ${Simox_EXTERNAL_LIBRARIES} simox-qhull powercrust)
+
+TARGET_LINK_LIBRARIES (GraspStudio Saba VirtualRobot ${Simox_EXTERNAL_LIBRARIES} ${QHULL_LIBRARIES} powercrust)
 
 # .DLL path
 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${Simox_BIN_DIR})
diff --git a/VirtualRobot/examples/SceneViewer/CMakeLists.txt b/VirtualRobot/examples/SceneViewer/CMakeLists.txt
index b888efe1a..e4521f4c8 100644
--- a/VirtualRobot/examples/SceneViewer/CMakeLists.txt
+++ b/VirtualRobot/examples/SceneViewer/CMakeLists.txt
@@ -1,4 +1,4 @@
-PROJECT ( SceneViewer )
+PROJECT ( SimoxSceneViewer )
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6.4)
 
diff --git a/config.cmake b/config.cmake
index 1dd57224d..7f16b0529 100644
--- a/config.cmake
+++ b/config.cmake
@@ -47,7 +47,7 @@ IF (NOT Simox_CONFIGURED)
 	############################# VERSION #################################
 	set(Simox_MAJOR_VERSION 2)
 	set(Simox_MINOR_VERSION 3)
-	set(Simox_PATCH_VERSION 8)
+	set(Simox_PATCH_VERSION 9)
 	set(Simox_VERSION
     ${Simox_MAJOR_VERSION}.${Simox_MINOR_VERSION}.${Simox_PATCH_VERSION})
 
-- 
GitLab