FindLIBLINEAR.cmake
Go to the documentation of this file.
1 ##############################################################################
2 # @file FindLIBLINEAR.cmake
3 # @brief Find LIBLINEAR package.
4 #
5 # @par Input varibales:
6 # <table border="0">
7 # <tr>
8 # @tp @b LIBLINEAR_DIR @endtp
9 # <td>The LIBLINEAR package files are searched primarily under the specified
10 # root directory. This variable can be alternatively set as environment
11 # variable.</td>
12 # </tr>
13 # <tr>
14 # @tp @b MEX_EXT @endtp
15 # <td>The extension of MEX-files. If this variable is not set and the
16 # basis_mexext command is available, it is invoked to determine the
17 # extension automatically. Otherwise, the MEX extension defaults to
18 # "mexa64".</td>
19 # </tr>
20 # </table>
21 #
22 # @par Output variables:
23 # <table border="0">
24 # <tr>
25 # @tp @b LIBLINEAR_FOUND @endtp
26 # <td>Whether the package was found and the following CMake variables are valid.</td>
27 # </tr>
28 # <tr>
29 # @tp @b LIBLINEAR_libsvmwrite_MEX @endtp
30 # <td>The libsvmwrite MEX-file.</td>
31 # </tr>
32 # <tr>
33 # @tp @b LIBLINEAR_libsvmread_MEX @endtp
34 # <td>The libsvmread MEX-file.</td>
35 # </tr>
36 # <tr>
37 # @tp @b LIBLINEAR_predict_MEX @endtp
38 # <td>The predict MEX-file.</td>
39 # </tr>
40 # <tr>
41 # @tp @b LIBLINEAR_train_MEX @endtp
42 # <td>The train MEX-file.</td>
43 # </tr>
44 # <tr>
45 # @tp @b LIBLINEAR_MEX_FILES @endtp
46 # <td>List of MEX-files (non-cached).</td>
47 # </tr>
48 # </table>
49 #
50 # @ingroup CMakeFindModules
51 ##############################################################################
52 
53 #=============================================================================
54 # Copyright 2011-2012 University of Pennsylvania
55 # Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com>
56 #
57 # Distributed under the OSI-approved BSD License (the "License");
58 # see accompanying file Copyright.txt for details.
59 #
60 # This software is distributed WITHOUT ANY WARRANTY; without even the
61 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
62 # See the License for more information.
63 #=============================================================================
64 # (To distribute this file outside of CMake, substitute the full
65 # License text for the above reference.)
66 
67 # ----------------------------------------------------------------------------
68 # initialize search
69 if (NOT LIBLINEAR_DIR)
70  set (LIBLINEAR_DIR "$ENV{LIBLINEAR_DIR}" CACHE PATH "Installation prefix for LIBLINEAR." FORCE)
71 endif ()
72 
73 if (NOT MEX_EXT)
75  basis_mexext (MEX_EXT)
76  else ()
77  set (MEX_EXT "mexa64")
78  endif ()
79 endif ()
80 
81 #--------------------------------------------------------------
82 # find paths/files
83 if (LIBLINEAR_DIR)
84 
85  find_file (
86  LIBLINEAR_libsvmwrite_MEX
87  NAMES libsvmwrite.${MEX_EXT}
88  HINTS ${LIBLINEAR_DIR}
89  PATH_SUFFIXES "matlab"
90  DOC "The libsvmwrite MEX-file of the LIBLINEAR library."
91  NO_DEFAULT_PATH
92  )
93 
94  find_file (
95  LIBLINEAR_libsvmread_MEX
96  NAMES libsvmread.${MEX_EXT}
97  HINTS ${LIBLINEAR_DIR}
98  PATH_SUFFIXES "matlab"
99  DOC "The libsvmread MEX-file of the LIBLINEAR library."
100  NO_DEFAULT_PATH
101  )
102 
103  find_file (
104  LIBLINEAR_train_MEX
105  NAMES train.${MEX_EXT}
106  HINTS ${LIBLINEAR_DIR}
107  PATH_SUFFIXES "matlab"
108  DOC "The train MEX-file of the LIBLINEAR library."
109  NO_DEFAULT_PATH
110  )
111 
112  find_file (
113  LIBLINEAR_predict_MEX
114  NAMES predict.${MEX_EXT}
115  HINTS ${LIBLINEAR_DIR}
116  PATH_SUFFIXES "matlab"
117  DOC "The predict MEX-file of the LIBLINEAR library."
118  NO_DEFAULT_PATH
119  )
120 
121 else ()
122 
123  find_file (
124  LIBLINEAR_libsvmwrite_MEX
125  NAMES libsvmwrite.${MEX_EXT}
126  PATH_SUFFIXES "matlab"
127  DOC "The libsvmwrite MEX-file of the LIBLINEAR library."
128  )
129 
130  find_file (
131  LIBLINEAR_libsvmread_MEX
132  NAMES libsvmread.${MEX_EXT}
133  PATH_SUFFIXES "matlab"
134  DOC "The libsvmread MEX-file of the LIBLINEAR library."
135  )
136 
137  find_file (
138  LIBLINEAR_train_MEX
139  NAMES train.${MEX_EXT}
140  PATH_SUFFIXES "matlab"
141  DOC "The train MEX-file of the LIBLINEAR library."
142  )
143 
144  find_file (
145  LIBLINEAR_predict_MEX
146  NAMES predict.${MEX_EXT}
147  PATH_SUFFIXES "matlab"
148  DOC "The predict MEX-file of the LIBLINEAR library."
149  )
150 
151 endif ()
152 
153 mark_as_advanced (LIBLINEAR_libsvmread_MEX)
154 mark_as_advanced (LIBLINEAR_libsvmwrite_MEX)
155 mark_as_advanced (LIBLINEAR_train_MEX)
156 mark_as_advanced (LIBLINEAR_predict_MEX)
157 
158 set (LIBLINEAR_MEX_FILES)
159 if (LIBLINEAR_libsvmread_MEX)
160  list (APPEND LIBLINEAR_MEX_FILES "${LIBLINEAR_libsvmread_MEX}")
161 endif ()
162 if (LIBLINEAR_libsvmwrite_MEX)
163  list (APPEND LIBLINEAR_MEX_FILES "${LIBLINEAR_libsvmwrite_MEX}")
164 endif ()
165 if (LIBLINEAR_train_MEX)
166  list (APPEND LIBLINEAR_MEX_FILES "${LIBLINEAR_train_MEX}")
167 endif ()
168 if (LIBLINEAR_predict_MEX)
169  list (APPEND LIBLINEAR_MEX_FILES "${LIBLINEAR_predict_MEX}")
170 endif ()
171 
172 # ----------------------------------------------------------------------------
173 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
174 # if all listed variables are found or TRUE
175 include (FindPackageHandleStandardArgs)
176 
177 find_package_handle_standard_args (
178  LIBLINEAR
179 # MESSAGE
180  DEFAULT_MSG
181 # VARIABLES
182  LIBLINEAR_libsvmwrite_MEX
183  LIBLINEAR_libsvmread_MEX
184  LIBLINEAR_predict_MEX
185  LIBLINEAR_train_MEX
186 )
187 
188 # ----------------------------------------------------------------------------
189 # set LIBLINEAR_DIR
190 if (NOT LIBLINEAR_DIR AND LIBLINEAR_FOUND)
191  string (REGEX REPLACE "matlab/[^/]+" "" LIBLINEAR_PREFIX "${LIBLINEAR_train_MEX}")
192  set (LIBLINEAR_DIR "${LIBLINEAR_PREFIX}" CACHE PATH "Installation prefix for LIBLINEAR." FORCE)
193  unset (LIBLINEAR_PREFIX)
194 endif ()
cmake LIBLINEAR_DIR
cmake COMMAND
function basis_mexext(out ARGN)
Determine extension of MEX-files for this architecture.
cmake MEX_EXT
if(oldcoutbuf)