1 ############################################################################## 3 # @brief Find programs of the AFNI package. 5 # @sa http://afni.nimh.nih.gov/afni/ 7 # @par Input variables: 10 # @tp @b AFNI_DIR @endtp 11 # <td>The AFNI package files are searched under the specified root 12 # directory. If they are not found there, the default search paths 13 # are considered. This variable can also be set as environment variable.</td> 16 # @tp @b AFNI_FIND_COMPONENTS @endtp 17 # <td>List of components, i.e., AFNI programs, to look for. 18 # Specify using COMPONENTS argument of find_package() command.</td> 21 # @tp @b AFNI_FIND_OPTIONAL_COMPONENTS @endtp 22 # <td>List of optional components, i.e., AFNI programs, to look for. 23 # Specify using OPTIONAL_COMPONENTS argument of find_package() command.</td> 27 # @par Output variables: 30 # @tp @b AFNI_FOUND @endtp 31 # <td>Whether all required programs of the AFNI package were found. If only 32 # optional programs were searched, this variable is set to @c TRUE if 33 # all named programs were found.</td> 36 # @tp @b AFNI_<tool>_EXECUTABLE @endtp 37 # <td>Absolute path of the corresponding found AFNI program, e.g., @c AFNI_3dcalc_EXECUTABLE.</td> 41 # @ingroup CMakeFindModules 42 ############################################################################## 44 #============================================================================= 45 # Copyright 2011-2012 University of Pennsylvania 46 # Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com> 48 # Distributed under the OSI-approved BSD License (the "License"); 49 # see accompanying file Copyright.txt for details. 51 # This software is distributed WITHOUT ANY WARRANTY; without even the 52 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 53 # See the License for more information. 54 #============================================================================= 55 # (To distribute this file outside of CMake, substitute the full 56 # License text for the above reference.) 58 # ---------------------------------------------------------------------------- 61 set (AFNI_DIR
"$ENV{AFNI_DIR}" CACHE PATH
"Installation prefix of AFNI." FORCE)
64 if (NOT AFNI_FIND_COMPONENTS AND NOT AFNI_FIND_OPTIONAL_COMPONENTS)
65 message (FATAL_ERROR
"The FindAFNI.cmake module requires a list of AFNI programs to look for" 66 " specified using the COMPONENTS and/or OPTIONAL_COMPONENTS argument" 67 " of the find_package() command, e.g.:" 69 "find_package(AFNI COMPONENTS 3dcalc)")
72 # ---------------------------------------------------------------------------- 73 # private helper macro to look for a particular required or optional AFNI program 74 macro (_AFNI_find_program
NAME REQUIRED)
76 find_program (AFNI_${
NAME}_EXECUTABLE NAMES ${
NAME} HINTS ${AFNI_DIR} PATH_SUFFIXES bin NO_DEFAULT_PATH)
78 find_program (AFNI_${
NAME}_EXECUTABLE NAMES ${
NAME})
80 if (NOT AFNI_${
NAME}_EXECUTABLE)
81 if (AFNI_FIND_COMPONENTS)
82 # looking either only for required components or for both optional and 83 # and required components; in this case, let AFNI_FOUND reflect only 84 # whether all required components were found, but ignore the optional ones; 85 # the caller can still check AFNI_<tool>_EXECUTABLE explicitly for these 86 # optional components to see whether or not a particular AFNI programs was found 91 # looking only for optional components anyway, so let AFNI_FOUND reflect 92 # if all of these optional components were found instead 96 list (APPEND _AFNI_MISSING_COMPONENTS ${
NAME})
98 list (APPEND _AFNI_MISSING_OPTIONAL_COMPONENTS ${
NAME})
101 mark_as_advanced (AFNI_${
NAME}_EXECUTABLE)
104 # ---------------------------------------------------------------------------- 105 # find AFNI program(s) 108 set (_AFNI_MISSING_COMPONENTS)
109 foreach (_AFNI_TOOL IN LISTS AFNI_FIND_COMPONENTS)
110 _AFNI_find_program (${_AFNI_TOOL} TRUE)
113 set (_AFNI_MISSING_OPTIONAL_COMPONENTS)
114 foreach (_AFNI_TOOL IN LISTS AFNI_FIND_OPTIONAL_COMPONENTS)
115 _AFNI_find_program (${_AFNI_TOOL} FALSE)
118 # ---------------------------------------------------------------------------- 119 # handle the QUIETLY and REQUIRED arguments 120 set (
_AFNI_HELP_MESSAGE "Please set AFNI_DIR to the directory containing these executables or specify the location of each not found executable using the advanced AFNI_<tool>_EXECUTABLE CMake variables.")
122 if (_AFNI_MISSING_COMPONENTS)
123 message (FATAL_ERROR
"Could NOT find the following required AFNI program(s):\n${_AFNI_MISSING_COMPONENTS}\n${_AFNI_HELP_MESSAGE}")
124 elseif (_AFNI_MISSING_OPTIONAL_COMPONENTS AND NOT AFNI_FIND_QUIETLY)
125 message (WARNING "Could NOT find the following optional AFNI program(s):\n${_AFNI_MISSING_OPTIONAL_COMPONENTS}\n${
_AFNI_HELP_MESSAGE}
") 128 # ---------------------------------------------------------------------------- 131 foreach (_AFNI_TOOL IN LISTS AFNI_FIND_COMPONENTS AFNI_FIND_OPTIONAL_COMPONENTS) 132 if (AFNI_${_AFNI_TOOL}_EXECUTABLE) 133 get_filename_component (AFNI_DIR "${AFNI_${_AFNI_TOOL}_EXECUTABLE}
" PATH) 134 string (REGEX REPLACE "/bin/?
" "" AFNI_DIR "${AFNI_DIR}
") 135 set (AFNI_DIR "${AFNI_DIR}
" CACHE PATH "Installation prefix of AFNI.
" FORCE) 143 unset (_AFNI_HELP_MESSAGE) 144 unset (_AFNI_MISSING_COMPONENTS) 145 unset (_AFNI_MISSING_OPTIONAL_COMPONENTS)