FindMatlabNiftiTools.cmake
Go to the documentation of this file.
1 ##############################################################################
2 # @file FindMatlabNiftiTools.cmake
3 # @brief Find MATLAB Central package "Tools for NIfTI and ANALYZE Image" (#8797).
4 #
5 # @par Input variables:
6 # <table border="0">
7 # <tr>
8 # @tp @b MatlabNiftiTools_DIR @endtp
9 # <td>The MATLAB Central package files are searched under the specified
10 # root directory. If they are not found there, the default search
11 # paths are considered. This variable can also be set as
12 # environment variable.</td>
13 # </tr>
14 # <tr>
15 # @tp @b MATLABNIFTITOOLS_DIR @endtp
16 # <td>Alternative environment variable for @p MatlabNiftiTools_DIR.</td>
17 # </tr>
18 # </table>
19 #
20 # @par Output variables:
21 # <table border="0">
22 # <tr>
23 # @tp @b MatlabNiftiTools_FOUND @endtp
24 # <td>Whether the package was found and the following CMake variables are valid.</td>
25 # </tr>
26 # <tr>
27 # @tp @b MatlabNiftiTools_INCLUDE_DIR @endtp
28 # <td>Cached include directory/ies only related to the searched package.</td>
29 # </tr>
30 # <tr>
31 # @tp @b MatlabNiftiTools_INCLUDE_DIRS @endtp
32 # <td>Include directory/ies of searched and dependent packages (not cached).</td>
33 # </tr>
34 # <tr>
35 # @tp @b MatlabNiftiTools_INCLUDES @endtp
36 # <td>Alias for MatlabNiftiTools_INCLUDE_DIRS (not cached).</td>
37 # </tr>
38 # </table>
39 #
40 # @ingroup CMakeFindModules
41 ##############################################################################
42 
43 #=============================================================================
44 # Copyright 2011-2012 University of Pennsylvania
45 # Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com>
46 #
47 # Distributed under the OSI-approved BSD License (the "License");
48 # see accompanying file Copyright.txt for details.
49 #
50 # This software is distributed WITHOUT ANY WARRANTY; without even the
51 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
52 # See the License for more information.
53 #=============================================================================
54 # (To distribute this file outside of CMake, substitute the full
55 # License text for the above reference.)
56 
57 # ----------------------------------------------------------------------------
58 # initialize search
59 if (NOT MatlabNiftiTools_DIR)
60  if (NOT $ENV{MATLABNIFTITOOLS_DIR} STREQUAL "")
61  set (MatlabNiftiTools_DIR "$ENV{MATLABNIFTITOOLS_DIR}" CACHE PATH "Installation prefix for MATLAB NIfTI tools." FORCE)
62  else ()
63  set (MatlabNiftiTools_DIR "$ENV{MatlabNiftiTools_DIR}" CACHE PATH "Installation prefix for MATLAB NIfTI tools." FORCE)
64  endif ()
65 endif ()
66 
67 # ----------------------------------------------------------------------------
68 # find paths / files
69 if (MatlabNiftiTools_DIR)
70 
71  find_path (
72  MatlabNiftiTools_INCLUDE_DIR
73  NAMES load_nii.m
74  HINTS ${MatlabNiftiTools_DIR}
75  DOC "path to directory containing load_nii.m"
76  NO_DEFAULT_PATH
77  )
78 
79 else ()
80 
81  find_path (
82  MatlabNiftiTools_INCLUDE_DIR
83  NAMES load_nii.m
84  HINTS ENV MATLABPATH
85  DOC "path to directory containing load_nii.m"
86  )
87 
88 endif ()
89 
90 # ----------------------------------------------------------------------------
91 # append paths / libraries of packages this package depends on
92 if (MatlabNiftiTools_INCLUDE_DIR)
93  set (MatlabNiftiTools_INCLUDE_DIRS "${MatlabNiftiTools_INCLUDE_DIR}")
94  set (MatlabNiftiTools_INCLUDES "${MatlabNiftiTools_INCLUDE_DIRS}")
95 endif ()
96 
97 # ----------------------------------------------------------------------------
98 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
99 # if all listed variables are found or TRUE
100 include (FindPackageHandleStandardArgs)
101 
102 find_package_handle_standard_args (
103  MatlabNiftiTools
104  REQUIRED_ARGS
105  MatlabNiftiTools_INCLUDE_DIR
106 )
107 
108 set (MatlabNiftiTools_FOUND "${MATLABNIFTITOOLS_FOUND}")
109 
110 # ----------------------------------------------------------------------------
111 # set MatlabNiftiTools_DIR
112 if (NOT MatlabNiftiTools_DIR AND MatlabNiftiTools_FOUND)
113  set (MatlabNiftiTools_DIR "${MatlabNiftiTools_INCLUDE_DIR}" CACHE PATH "Installation prefix for MATLAB NIfTI tools." FORCE)
114 endif ()
cmake MatlabNiftiTools_INCLUDES
cmake MatlabNiftiTools_DIR
cmake MatlabNiftiTools_INCLUDE_DIRS
cmake MatlabNiftiTools_FOUND