2 # Find the native Qhull includes and library
4 # QHULL_INCLUDE_DIR, where to find libqhullcpp/Qhull.h.
5 # QHULL_LIBRARIES, the libraries needed to use Qhull.
6 # QHULL_FOUND, If false, do not try to use Qhull.
7 # also defined, but not for general use are
9 find_path(QHULL_INCLUDE_DIR libqhullcpp/Qhull.h)
11 set(QHULL_LIBRARIES "")
12 set(QHULL_LIBRARIES_FOUND FALSE)
13 set(QHULL_LIBRARY_NAMES "")
14 set(QHULL_LINK_DIRS "")
16 set(_qhull_configurations release debug releasenoopt debugopt)
17 set(_qhull_libs_to_process qhullcpp qhullstatic_r)
18 set(_qhull_libs_found TRUE)
20 foreach(_qhull_config ${_qhull_configurations}) # release debug releasenoopt debugopt
21 string(TOUPPER ${_qhull_config} _qhull_config_uc) # RELEASE, ..., DEBUGOPT
23 if(${_qhull_config_uc} STREQUAL "RELEASE")
24 set(_qhull_lib_suffix "")
26 if(${_qhull_config_uc} STREQUAL "DEBUG")
27 set(_qhull_lib_suffix "D")
29 if(${_qhull_config_uc} STREQUAL "RELEASENOOPT")
30 set(_qhull_lib_suffix "RN")
32 if(${_qhull_config_uc} STREQUAL "DEBUGOPT")
33 set(_qhull_lib_suffix "DO")
36 foreach(_qhull_lib ${_qhull_libs_to_process}) # qhullcpp qhullstatic_r
37 string(TOUPPER ${_qhull_lib} _qhull_lib_uc) # QHULLCPP, QHULLSTATIC_R
39 set(QHULL_${_qhull_lib_uc}_NAMES_${_qhull_config_uc} ${_qhull_lib}${_qhull_lib_suffix}) # set(QHULL_QHULLCPP_NAMES_DEBUGOPT qhullcppDO)
40 find_library(QHULL_${_qhull_lib_uc}_LIBRARY_${_qhull_config_uc} NAMES ${QHULL_${_qhull_lib_uc}_NAMES_${_qhull_config_uc}}) # find_library(QHULL_QHULLCPP_LIBRARY_DEBUGOPT NAMES ${QHULL_QHULLCPP_NAMES_DEBUGOPT})
42 set(_qhull_found_this_lib TRUE)
43 if(NOT QHULL_${_qhull_lib_uc}_LIBRARY_${_qhull_config_uc}) # if(NOT QHULL_QHULLCPP_LIBRARY_DEBUGOPT)
44 set(_qhull_found_this_lib FALSE)
47 if(_qhull_found_this_lib)
48 list(APPEND QHULL_LIBRARY_NAMES ${_qhull_lib_uc}) # list(APPEND QHULL_LIBRARY_NAMES QHULLCPP)
49 list(APPEND _qhull_all_found_${_qhull_config}_libs ${QHULL_${_qhull_lib_uc}_LIBRARY_${_qhull_config_uc}}) # list(APPEND _qhull_all_found_debugopt_libs ${QHULL_QHULLCPP_LIBRARY_DEBUGOPT})
50 mark_as_advanced(QHULL_${_qhull_lib_uc}_LIBRARY_${_qhull_config_uc}) # mark_as_advanced(QHULL_QHULLCPP_LIBRARY_DEBUGOPT)
51 get_filename_component(_qhull_dir ${QHULL_${_qhull_lib_uc}_LIBRARY_${_qhull_config_uc}} PATH) # get_filename_component(_qhull_dir ${QHULL_QHULLCPP_LIBRARY_DEBUGOPT} PATH)
52 list(APPEND QHULL_LINK_DIRS ${_qhull_dir})
60 list(REMOVE_DUPLICATES QHULL_LIBRARY_NAMES)
61 list(REMOVE_DUPLICATES QHULL_LINK_DIRS)
63 foreach(_qhull_name ${QHULL_LIBRARY_NAMES}) # QHULLCPP QHULLSTATIC_R
64 set(QHULL_${_qhull_name}_FOUND TRUE) # set(QHULL_QHULLCPP_FOUND TRUE)
65 set(QHULL_${_qhull_name}_LIBRARY QHULL_${_qhull_name}_LIBRARY_TARGET) # set(QHULL_QHULLCPP_LIBRARY QHULL_QHULLCPP_LIBRARY_TARGET)
66 mark_as_advanced(QHULL_${_qhull_name}_LIBRARY) # mark_as_advanced(QHULL_QHULLCPP_LIBRARY)
68 set(_qhull_lib_name ${QHULL_${_qhull_name}_LIBRARY}) # set(_qhull_lib_name ${QHULL_QHULLCPP_LIBRARY})
69 set(_qhull_lib_name_uc ${_qhull_name}) # set(_qhull_lib_name_uc QHULLCPP)
71 add_library(${_qhull_lib_name} UNKNOWN IMPORTED) # add_library(${QHULL_QHULLCPP_LIBRARY} UNKNOWN IMPORTED)
73 if(QHULL_${_qhull_lib_name_uc}_LIBRARY_RELEASE) # if(QHULL_QHULLCPP_LIBRARY_RELEASE)
74 set(_qhull_imp_release IMPORTED_LOCATION_RELEASE ${QHULL_${_qhull_lib_name_uc}_LIBRARY_RELEASE}) # set(_qhull_imp_release IMPORTED_LOCATION_RELEASE ${QHULL_QHULLCPP_LIBRARY_RELEASE})
77 if(QHULL_${_qhull_lib_name_uc}_LIBRARY_RELEASENOOPT) # if(QHULL_QHULLCPP_LIBRARY_RELEASENOOPT)
78 set(_qhull_imp_releasenoopt IMPORTED_LOCATION_RELEASENOOPT ${QHULL_${_qhull_lib_name_uc}_LIBRARY_RELEASENOOPT}) # set(_qhull_imp_releasenoopt IMPORTED_LOCATION_RELEASENOOPT ${QHULL_QHULLCPP_LIBRARY_RELEASENOOPT})
81 if(QHULL_${_qhull_lib_name_uc}_LIBRARY_DEBUG) # if(QHULL_QHULLCPP_LIBRARY_DEBUG)
82 set(_qhull_imp_debug IMPORTED_LOCATION_DEBUG ${QHULL_${_qhull_lib_name_uc}_LIBRARY_DEBUG}) # set(_qhull_imp_debug IMPORTED_LOCATION_DEBUG ${QHULL_QHULLCPP_LIBRARY_DEBUG})
85 if(QHULL_${_qhull_lib_name_uc}_LIBRARY_DEBUGOPT) # if(QHULL_QHULLCPP_LIBRARY_DEBUGOPT)
86 set(_qhull_imp_debugopt IMPORTED_LOCATION_DEBUGOPT ${QHULL_${_qhull_lib_name_uc}_LIBRARY_DEBUGOPT}) # set(_qhull_imp_debugopt IMPORTED_LOCATION_DEBUGOPT ${QHULL_QHULLCPP_LIBRARY_DEBUGOPT})
89 if(_qhull_imp_release OR _qhull_imp_releasenoopt OR _qhull_imp_debug OR _qhull_imp_debugopt)
90 set_target_properties(
91 ${_qhull_lib_name} PROPERTIES # ${QHULL_QHULLCPP_LIBRARY} PROPERTIES
92 ${_qhull_imp_release} # IMPORTED_LOCATION_RELEASE ${QHULL_QHULLCPP_LIBRARY_RELEASE}
93 ${_qhull_imp_releasenoopt} # IMPORTED_LOCATION_RELEASENOOPT ${QHULL_QHULLCPP_LIBRARY_RELEASENOOPT}
94 ${_qhull_imp_debug} # IMPORTED_LOCATION_DEBUG ${QHULL_QHULLCPP_LIBRARY_DEBUG}
95 ${_qhull_imp_debugopt} # IMPORTED_LOCATION_DEBUGOPT ${QHULL_QHULLCPP_LIBRARY_DEBUGOPT}
98 list(APPEND QHULL_LIBRARIES ${QHULL_${_qhull_name}_LIBRARY}) # list(APPEND QHULL_LIBRARIES ${QHULL_QHULLCPP_LIBRARY})
102 include(FindPackageHandleStandardArgs)
103 FIND_PACKAGE_HANDLE_STANDARD_ARGS(QHULL DEFAULT_MSG QHULL_LIBRARIES QHULL_INCLUDE_DIR)
104 set(QHULL_LIBRARIES_FOUND TRUE)
105 mark_as_advanced(QHULL_LIBRARIES_FOUND QHULL_INCLUDE_DIR)