--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -333,30 +333,29 @@ set(
         index.htm
 )
 
-include_directories(${CMAKE_SOURCE_DIR}/src)
-
-if(CMAKE_BUILD_TYPE MATCHES "[dD]ebug")
-    set(qhull_CPP qhullcpp_d)
-    set(qhull_SHARED qhull_d) 
-    set(qhull_SHAREDP qhull_pd)
-    set(qhull_SHAREDR qhull_rd)
-    set(qhull_STATIC qhullstatic_d)
-    set(qhull_STATICR qhullstatic_rd)
-else()
-    set(qhull_CPP qhullcpp)
-    set(qhull_SHARED libqhull)  # Temporarily avoid name conflict with qhull executable
-    set(qhull_SHAREDP qhull_p)
-    set(qhull_SHAREDR qhull_r)
-    set(qhull_STATIC qhullstatic)
-    set(qhull_STATICR qhullstatic_r)
-endif()
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
 
+set(qhull_CPP qhullcpp)
+set(qhull_SHARED libqhull)  # Temporarily avoid name conflict with qhull executable
+set(qhull_SHAREDP qhull_p)
+set(qhull_SHAREDR qhull_r)
+set(qhull_STATIC qhullstatic)
+set(qhull_STATICR qhullstatic_r)
+
+if(BUILD_SHARED_LIBS)
+set(
+    qhull_TARGETS_INSTALL
+        ${qhull_SHAREDR}
+        qhull rbox qconvex qdelaunay qvoronoi qhalf
+        ${qhull_SHARED}
+)
+else()
 set(
     qhull_TARGETS_INSTALL
-        ${qhull_CPP} ${qhull_STATIC} ${qhull_STATICR} ${qhull_SHAREDR}
+        ${qhull_STATIC} ${qhull_STATICR}
         qhull rbox qconvex qdelaunay qvoronoi qhalf
-        ${qhull_SHARED} ${qhull_SHAREDP}  # Deprecated, use qhull_r instead
 )
+endif()
 set(
     qhull_TARGETS_TEST   # Unused
         user_eg user_eg2 user_eg3 user_egp testqset testqset_r
@@ -371,7 +370,8 @@ add_library(${qhull_SHAREDR} SHARED
         src/libqhull_r/qhull_r-exports.def)
 set_target_properties(${qhull_SHAREDR} PROPERTIES
     SOVERSION ${qhull_SOVERSION}
-    VERSION ${qhull_VERSION})
+    VERSION ${qhull_VERSION}
+    OUTPUT_NAME "${qhull_SHAREDR}$<$<CONFIG:Debug>:d>")
 
 if(UNIX)
     target_link_libraries(${qhull_SHAREDR} m)
@@ -393,16 +393,11 @@ endif(UNIX)
 add_library(${qhull_SHARED} SHARED 
         ${libqhull_SOURCES}
         src/libqhull/qhull-exports.def)
-        
-if(qhull_SHARED MATCHES "libqhull")
-   set(qhull_OUTPUT_NAME qhull)
-   set_target_properties(${qhull_SHARED} PROPERTIES
-        OUTPUT_NAME "${qhull_OUTPUT_NAME}" )
-endif()
 
 set_target_properties(${qhull_SHARED} PROPERTIES
     SOVERSION ${qhull_SOVERSION}
-    VERSION ${qhull_VERSION})
+    VERSION ${qhull_VERSION}
+    OUTPUT_NAME "qhull$<$<CONFIG:Debug>:_d>")
 
 if(UNIX)
     target_link_libraries(${qhull_SHARED} m)
@@ -427,7 +422,8 @@ add_library(${qhull_SHAREDP} SHARED
 set_target_properties(${qhull_SHAREDP} PROPERTIES
     COMPILE_DEFINITIONS "qh_QHpointer"
     SOVERSION ${qhull_SOVERSION}
-    VERSION ${qhull_VERSION})
+    VERSION ${qhull_VERSION}
+    OUTPUT_NAME "${qhull_SHAREDP}$<$<CONFIG:Debug>:d>")
 
 if(UNIX)
     target_link_libraries(${qhull_SHAREDP} m)
@@ -448,11 +444,13 @@ endif(UNIX)
 
 add_library(${qhull_STATIC} STATIC ${libqhull_SOURCES})
 set_target_properties(${qhull_STATIC} PROPERTIES
-    VERSION ${qhull_VERSION})
+    VERSION ${qhull_VERSION}
+    OUTPUT_NAME "${qhull_STATIC}$<$<CONFIG:Debug>:_d>")
 
 add_library(${qhull_STATICR} STATIC ${libqhullr_SOURCES})
 set_target_properties(${qhull_STATICR} PROPERTIES
-    VERSION ${qhull_VERSION})
+    VERSION ${qhull_VERSION}
+    OUTPUT_NAME "${qhull_STATICR}$<$<CONFIG:Debug>:d>")
 
 if(UNIX)
     target_link_libraries(${qhull_STATIC} m)
@@ -466,7 +464,8 @@ endif(UNIX)
 
 add_library(${qhull_CPP} STATIC ${libqhullcpp_SOURCES})
 set_target_properties(${qhull_CPP} PROPERTIES
-    VERSION ${qhull_VERSION})
+    VERSION ${qhull_VERSION}
+    OUTPUT_NAME "${qhull_CPP}$<$<CONFIG:Debug>:_d>")
 
 # ---------------------------------------
 # Define qhull executables linked to qhullstatic library
@@ -661,10 +660,7 @@ install(
 )
 
 install(FILES ${libqhull_HEADERS}    DESTINATION ${INCLUDE_INSTALL_DIR}/libqhull)
-install(FILES ${libqhull_DOC}        DESTINATION ${INCLUDE_INSTALL_DIR}/libqhull)
 install(FILES ${libqhullr_HEADERS}    DESTINATION ${INCLUDE_INSTALL_DIR}/libqhull_r)
-install(FILES ${libqhullr_DOC}        DESTINATION ${INCLUDE_INSTALL_DIR}/libqhull_r)
-install(FILES ${libqhullcpp_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/libqhullcpp)
 install(FILES html/qhull.man         DESTINATION ${MAN_INSTALL_DIR} RENAME qhull.1)
 install(FILES html/rbox.man          DESTINATION ${MAN_INSTALL_DIR} RENAME rbox.1)
 install(FILES ${doc_FILES}           DESTINATION ${DOC_INSTALL_DIR})
