From 6e3558e3fd71b39d4bc2fdac1b4e51ea15b563da Mon Sep 17 00:00:00 2001
From: Brad Barber <bradb@shore.net>
Date: Sat, 23 Jan 2010 12:21:51 -0500
Subject: [PATCH] - Updated CMakeLists.txt to compile shared and static
 libraries and link the    command line utilities to the shared one.  Allows
 install of    targets, libqhull.h, and html docs.  [M. Moll] - Fixed location
 of qhull.man and rbox.man in src/Makefile.txt [M. Moll] n

---
 CMakeLists.txt     |  1 +
 src/CMakeLists.txt | 29 ++++++++++++++++++++---------
 src/Makefile.txt   |  4 ++--
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e55b0a9..61c978e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,3 +6,4 @@ endif(COMMAND cmake_policy)
 
 add_subdirectory(src)
 
+install(DIRECTORY html DESTINATION share/doc/qhull)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 62216e8..debc104 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,19 +23,25 @@ set(
 
 file(GLOB qhull_hdr *.h)
 
-add_library(qhull ${qhull_src})
+add_library(qhull SHARED ${qhull_src})
 target_link_libraries(qhull m)
-
-set(qhullcmd_SOURCES  unix.c)
-set(rbox_SOURCES  rbox.c)
-set(qconvex_SOURCES  qconvex.c)
-set(qdelaunay_SOURCES  qdelaun.c)
-set(qvoronoi_SOURCES  qvoronoi.c)
-set(qhalf_SOURCES  qhalf.c)
-
+if(UNIX)
+    if(APPLE)
+        set_target_properties(qhull PROPERTIES set(qhullcmd_SOURCES  unix.c)
+                INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")set(rbox_SOURCES  rbox.c)
+    else(APPLE)set(qconvex_SOURCES  qconvex.c)
+        set_target_properties(qhull PROPERTIES set(qdelaunay_SOURCES  qdelaun.c)
+                INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"set(qvoronoi_SOURCES  qvoronoi.c)
+                INSTALL_RPATH_USE_LINK_PATH TRUEset(qhalf_SOURCES  qhalf.c)
+                BUILD_WITH_INSTALL_RPATH FALSE)
+    endif(APPLE)
+endif(UNIX)
+add_library(qhullstatic STATIC ${qhull_src})
+set_property(TARGET qhullstatic PROPERTY OUTPUT_NAME "qhull")
 
 add_executable(qhullcmd ${qhullcmd_SOURCES})
 target_link_libraries(qhullcmd qhull)
+set_property(TARGET qhullcmd PROPERTY OUTPUT_NAME "qhull")
 
 add_executable(rbox ${rbox_SOURCES})
 target_link_libraries(rbox qhull)
@@ -52,3 +58,8 @@ target_link_libraries(qvoronoi qhull)
 add_executable(qhalf ${qhalf_SOURCES})
 target_link_libraries(qhalf qhull)
 
+install(TARGETS qhull qhullstatic qhullcmd rbox qconvex qdelaunay qvoronoi qhalf
+        RUNTIME DESTINATION bin
+        LIBRARY DESTINATION lib
+        ARCHIVE DESTINATION lib)
+install(FILES libqhull.h DESTINATION include)
diff --git a/src/Makefile.txt b/src/Makefile.txt
index 62a3a89..238a59e 100644
--- a/src/Makefile.txt
+++ b/src/Makefile.txt
@@ -74,9 +74,9 @@ HFILES= user.h libqhull.h qhull_a.h geom.h io.h mem.h merge.h poly.h random.h qs
 TXTFILES= ../Announce.txt ../REGISTER.txt ../COPYING.txt ../README.txt Changes.txt
 DOCFILES= ../html/rbox.txt ../html/qhull.txt
 FILES=	Makefile rbox.c user_eg.c ../eg/q_test ../eg/q_egtest ../eg/q_eg
-HTMFILES= qhull.man rbox.man qh-code.htm qh-optg.htm qh-optt.htm qh-optp.htm \
+HTMFILES= ../html/qhull.man ../html/rbox.man qh-code.htm qh-optg.htm qh-optt.htm \
 		index.htm qh-quick.htm qh-impre.htm qh-eg.htm \
-		qh-optc.htm qh-opto.htm qh-optf.htm qh-optq.htm \
+                qh-optc.htm qh-opto.htm qh-optf.htm  qh-optp.htm qh-optq.htm \
 		qh-c.htm qh-faq.htm qhull.htm qconvex.htm qdelaun.htm \
 		qh-geom.htm qh-globa.htm qh-io.htm qh-mem.htm qh-merge.htm \
 		qh-poly.htm qh-qhull.htm qh-set.htm qh-stat.htm qh-user.htm \
-- 
GitLab