FindSVMTorch.cmake
Go to the documentation of this file.
00001 ############################################################################## 00002 # @file FindSVMTorch.cmake 00003 # @brief Find SVMTorch II package. 00004 # 00005 # @par Input varibales: 00006 # <table border="0"> 00007 # <tr> 00008 # @tp @b SVMTorch_DIR @endtp 00009 # <td>The SVMTorch package files are searched primarily under the specified 00010 # root directory. This variable can be alternatively set as environment 00011 # variable.</td> 00012 # </tr> 00013 # <tr> 00014 # @tp @b SVMTorch_FIND_COMPONENTS @endtp 00015 # <td>@c COMPONENTS of SVMTorch to look for: @c train, @c test, @c lib. (default: @c train, @c test)</td> 00016 # </tr> 00017 # <tr> 00018 # @tp @b SVMTorch_FIND_OPTIONAL_COMPONENTS @endtp 00019 # <td>@c OPTIONAL_COMPONENTS of SVMTorch to look for: @c train, @c test, @c lib. (default: @c lib)</td> 00020 # </tr> 00021 # </table> 00022 # 00023 # @par Output variables: 00024 # <table border="0"> 00025 # <tr> 00026 # @tp @b SVMTorch_FOUND @endtp 00027 # <td>Whether the package was found and the following CMake variables are valid.</td> 00028 # </tr> 00029 # <tr> 00030 # @tp @b SVMTorch_INCLUDE_DIR @endtp 00031 # <td>The directory containing the include files.</td> 00032 # </tr> 00033 # <tr> 00034 # @tp @b SVMTorch_LIBRARY @endtp 00035 # <td>Found object files (.o).</td> 00036 # </tr> 00037 # <tr> 00038 # @tp @b SVMTorch_train_EXECUTABLE @endtp 00039 # <td>Absolute path of found @c SVMTorch executable.</td> 00040 # </tr> 00041 # <tr> 00042 # @tp @b SVMTorch_test_EXECUTABLE @endtp 00043 # <td>Absolute path of found @c SVMTest executable.</td> 00044 # </tr> 00045 # <tr> 00046 # @tp @b svmtorch.SVMTorch @endtp 00047 # <td>Import target of @c SVMTorch executable.</td> 00048 # </tr> 00049 # <tr> 00050 # @tp @b svmtorch.SVMTest @endtp 00051 # <td>Import target of @c SVMTest executable.</td> 00052 # </tr> 00053 # </table> 00054 # 00055 # Copyright (c) 2012 University of Pennsylvania. All rights reserved.<br /> 00056 # See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file. 00057 # 00058 # Contact: SBIA Group <sbia-software at uphs.upenn.edu> 00059 # 00060 # @ingroup CMakeFindModules 00061 ############################################################################## 00062 00063 # ---------------------------------------------------------------------------- 00064 # initialize search 00065 if (NOT SVMTorch_DIR) 00066 set (SVMTorch_DIR "$ENV{SVMTorch_DIR}" CACHE PATH "Installation prefix of SVMTorch." FORCE) 00067 endif () 00068 00069 if (NOT SVMTorch_FIND_COMPONENTS AND NOT SVMTorch_FIND_OPTIONAL_COMPONENTS) 00070 set (SVMTorch_FIND_COMPONENTS train test) 00071 set (SVMTorch_FIND_OPTIONAL_COMPONENTS lib) 00072 endif () 00073 00074 set (_SVMTorch_COMPONENTS ${SVMTorch_FIND_COMPONENTS} ${SVMTorch_FIND_OPTIONAL_COMPONENTS}) 00075 00076 foreach (_SVMTorch_C IN LISTS _SVMTorch_COMPONENTS) 00077 if (NOT _SVMTorch_C MATCHES "^(train|test|lib)$") 00078 message (FATAL_ERROR "Invalid SVMTorch component: ${_SVMTorch_C}") 00079 endif () 00080 endforeach () 00081 unset (_SVMTorch_C) 00082 00083 #-------------------------------------------------------------- 00084 # find executables 00085 if (_SVMTorch_COMPONENTS MATCHES train) 00086 if (SVMTorch_DIR) 00087 find_program ( 00088 SVMTorch_train_EXECUTABLE 00089 NAMES SVMTorch 00090 HINTS ${SVMTorch_DIR} 00091 DOC "The SVMTorch executable." 00092 NO_DEFAULT_PATH 00093 ) 00094 else () 00095 find_program ( 00096 SVMTorch_train_EXECUTABLE 00097 NAMES SVMTorch 00098 DOC "The SVMTorch executable." 00099 ) 00100 endif () 00101 mark_as_advanced (SVMTorch_train_EXECUTABLE) 00102 if (SVMTorch_train_EXECUTABLE) 00103 add_executable (svmtorch.SVMTorch IMPORTED) 00104 set_target_properties (svmtorch.SVMTorch PROPERTIES IMPORTED_LOCATION "${SVMTorch_train_EXECUTABLE}") 00105 endif () 00106 endif () 00107 00108 if (_SVMTorch_COMPONENTS MATCHES test) 00109 if (SVMTorch_DIR) 00110 find_program ( 00111 SVMTorch_test_EXECUTABLE 00112 NAMES SVMTest 00113 HINTS ${SVMTorch_DIR} 00114 DOC "The SVMTest executable." 00115 NO_DEFAULT_PATH 00116 ) 00117 else () 00118 find_program ( 00119 SVMTorch_test_EXECUTABLE 00120 NAMES SVMTest 00121 DOC "The SVMTest executable." 00122 ) 00123 endif () 00124 mark_as_advanced (SVMTorch_test_EXECUTABLE) 00125 if (SVMTorch_test_EXECUTABLE) 00126 add_executable (svmtorch.SVMTest IMPORTED) 00127 set_target_properties (svmtorch.SVMTest PROPERTIES IMPORTED_LOCATION "${SVMTorch_test_EXECUTABLE}") 00128 endif () 00129 endif () 00130 00131 #-------------------------------------------------------------- 00132 # derive SVMTorch_DIR if not set yet 00133 if (NOT SVMTorch_DIR) 00134 if (SVMTorch_train_EXECUTABLE) 00135 get_filename_component (SVMTorch_DIR "${SVMTorch_train_EXECUTABLE}" PATH) 00136 elseif (SVMTorch_test_EXECUTABLE) 00137 get_filename_component (SVMTorch_DIR "${SVMTorch_test_EXECUTABLE}" PATH) 00138 endif () 00139 set (SVMTorch_DIR "${SVMTorch_DIR}" CACHE PATH "Installation prefix of SVMTorch." FORCE) 00140 endif () 00141 00142 #-------------------------------------------------------------- 00143 # find header files and built object files 00144 set (SVMTorch_LIBRARY) 00145 if (_SVMTorch_COMPONENTS MATCHES lib) 00146 if (SVMTorch_DIR) 00147 find_path ( 00148 SVMTorch_INCLUDE_DIR 00149 NAMES IOTorch.h 00150 HINTS "${SVMTorch_DIR}" 00151 DOC "Directory containing the header files of SVMTorch (i.e., IOTorch.h)." 00152 NO_DEFAULT_PATH 00153 ) 00154 file (GLOB SVMTorch_OBJ_FILES "${SVMTorch_DIR}/*.o") 00155 foreach (_SVMTorch_OBJ_FILE IN LISTS SVMTorch_OBJ_FILES) 00156 if (NOT _SVMTorch_OBJ_FILE MATCHES "convert.o$|SVMTorch.o$|SVMTest.o$") 00157 list (APPEND SVMTorch_LIBRARY "${_SVMTorch_OBJ_FILE}") 00158 endif () 00159 endforeach () 00160 unset (_SVMTorch_OBJ_FILE) 00161 mark_as_advanced (SVMTorch_INCLUDE_DIR) 00162 else () 00163 find_path ( 00164 SVMTorch_INCLUDE_DIR 00165 NAMES IOTorch.h 00166 DOC "Directory containing the header files of SVMTorch (i.e., IOTorch.h)." 00167 ) 00168 mark_as_advanced (SVMTorch_INCLUDE_DIR) 00169 endif () 00170 endif () 00171 00172 # ---------------------------------------------------------------------------- 00173 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE 00174 # if all listed variables are found or TRUE 00175 include (FindPackageHandleStandardArgs) 00176 00177 set (SVMTorch_REQUIRED_VARS) 00178 if (SVMTorch_FIND_COMPONENTS MATCHES train) 00179 list (APPEND SVMTorch_REQUIRED_VARS SVMTorch_train_EXECUTABLE) 00180 endif () 00181 if (SVMTorch_FIND_COMPONENTS MATCHES test) 00182 list (APPEND SVMTorch_REQUIRED_VARS SVMTorch_test_EXECUTABLE) 00183 endif () 00184 if (SVMTorch_FIND_COMPONENTS MATCHES lib) 00185 list (APPEND SVMTorch_REQUIRED_VARS SVMTorch_INCLUDE_DIR) 00186 list (APPEND SVMTorch_REQUIRED_VARS SVMTorch_LIBRARY) 00187 endif () 00188 00189 find_package_handle_standard_args (SVMTorch DEFAULT_MSG ${SVMTorch_REQUIRED_VARS}) 00190 00191 00192 unset (_SVMTorch_COMPONENTS)