1 ############################################################################## 2 # @file FindNiftiCLib.cmake 3 # @brief Find nifticlib package. 5 # @par Input variables: 8 # @tp @b NiftiCLib_DIR @endtp 9 # <td>The nifticlib package files are searched under the specified root 10 # directory. If they are not found there, the default search paths 11 # are considered. This variable can also be set as environment variable.</td> 14 # @tp @b NIFTICLIB_DIR @endtp 15 # <td>Alternative environment variable for @p NiftiCLib_DIR.</td> 18 # @tp @b NiftiCLib_USE_STATIC_LIB @endtp 19 # <td>Forces this module to search for the static library. Otherwise, 20 # the shared library is preferred.</td> 24 # @par Output variables: 27 # @tp @b NiftiCLib_FOUND @endtp 28 # <td>Whether the nifticlib package was found and the following CMake 29 # variables are valid.</td> 32 # @tp @b NiftiCLib_INCLUDE_DIR @endtp 33 # <td>Cached include directory/ies.</td> 36 # @tp @b NiftiCLib_INCLUDE_DIRS @endtp 37 # <td>Alias for @p NiftiCLib_INCLUDE_DIR (not cached).</td> 40 # @tp @b NiftiCLib_INCLUDES @endtp 41 # <td>Alias for @p NiftiCLib_INCLUDE_DIR (not cached).</td> 44 # @tp @b NiftiCLib_LIBRARY @endtp 45 # <td>Path of @c niftiio library.</td> 48 # @tp @b NiftiCLib_LIB @endtp 49 # <td>Alias for @p NiftiCLib_LIBRARY (not cached).</td> 52 # @tp @b NiftiCLib_LIBRARIES @endtp 53 # <td>Path of @c niftiio library and prerequisite libraries.</td> 57 # @par Imported targets: 60 # @tp @b niftiio @endtp 61 # <td>The library target of the @c nifticlib library.</td> 65 # @ingroup CMakeFindModules 66 ############################################################################## 68 #============================================================================= 69 # Copyright 2011-2012 University of Pennsylvania 70 # Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com> 72 # Distributed under the OSI-approved BSD License (the "License"); 73 # see accompanying file Copyright.txt for details. 75 # This software is distributed WITHOUT ANY WARRANTY; without even the 76 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 77 # See the License for more information. 78 #============================================================================= 79 # (To distribute this file outside of CMake, substitute the full 80 # License text for the above reference.) 82 # ---------------------------------------------------------------------------- 85 if (NOT
"$ENV{NIFTICLIB_DIR}" STREQUAL
"")
86 set (NiftiCLib_DIR
"$ENV{NIFTICLIB_DIR}" CACHE PATH
"Installation prefix for NiftiCLib." FORCE)
88 set (NiftiCLib_DIR
"$ENV{NiftiCLib_DIR}" CACHE PATH
"Installation prefix for NiftiCLib." FORCE)
94 if (NiftiCLib_USE_STATIC_LIB)
110 # ---------------------------------------------------------------------------- 115 NiftiCLib_INCLUDE_DIR
116 NAMES nifti/nifti1_io.h
117 HINTS ${NiftiCLib_DIR}
118 PATH_SUFFIXES
"include" 119 DOC
"path to directory containing nifti1_io.h file." 126 HINTS ${NiftiCLib_DIR}
128 DOC
"Path of niftiio library" 133 NiftiCLib_znz_LIBRARY
135 HINTS ENV LD_LIBRARY_PATH
136 DOC
"Path of znz library" 142 NiftiCLib_INCLUDE_DIR
143 NAMES nifti/nifti1_io.h
144 HINTS ENV C_INCLUDE_PATH ENV CXX_INCLUDE_PATH
145 DOC
"path to directory containing nifti1_io.h file." 151 HINTS ENV LD_LIBRARY_PATH
152 DOC
"Path of niftiio library" 156 NiftiCLib_znz_LIBRARY
158 HINTS ENV LD_LIBRARY_PATH
159 DOC
"Path of znz library" 164 mark_as_advanced (NiftiCLib_INCLUDE_DIR)
165 mark_as_advanced (NiftiCLib_LIBRARY)
166 mark_as_advanced (NiftiCLib_znz_LIBRARY)
168 # ---------------------------------------------------------------------------- 170 if (NiftiCLib_USE_STATIC_LIB OR NiftiCLib_znz_LIBRARY MATCHES
"\\.a$")
175 if (NiftiCLib_znz_LIBRARY) 176 list (APPEND NiftiCLib_LIBRARIES "${NiftiCLib_znz_LIBRARY}
") 178 if (NiftiCLib_LIBRARY) 179 list (APPEND NiftiCLib_LIBRARIES "${NiftiCLib_LIBRARY}
") 182 # ---------------------------------------------------------------------------- 184 if (NiftiCLib_znz_LIBRARY) 185 if (NiftiCLib_USE_STATIC_LIB OR NiftiCLib_znz_LIBRARY MATCHES "\\.a$
") 186 add_library (niftiznz STATIC IMPORTED) 188 add_library (niftiznz SHARED IMPORTED) 190 set_target_properties ( 193 IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" 194 IMPORTED_LOCATION "${NiftiCLib_znz_LIBRARY}
" 195 IMPORTED_LINK_INTERFACE_LIBRARIES "${ZLIB_LIBRARIES}
" 199 if (NiftiCLib_LIBRARY) 200 if (NiftiCLib_USE_STATIC_LIB OR NiftiCLib_LIBRARY MATCHES "\\.a$
") 201 add_library (niftiio STATIC IMPORTED) 203 add_library (niftiio SHARED IMPORTED) 205 set_target_properties ( 208 IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" 209 IMPORTED_LOCATION "${NiftiCLib_LIBRARY}
" 212 set_target_properties (niftiio PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES niftiznz) 216 # ---------------------------------------------------------------------------- 217 # aliases / backwards compatibility 218 if (NiftiCLib_INCLUDE_DIR) 219 set (NiftiCLib_INCLUDE_DIRS "${NiftiCLib_INCLUDE_DIR}
") 220 if (NOT NiftiCLib_INCLUDE_DIR MATCHES "/nifti/?$
") 221 list (APPEND NiftiCLib_INCLUDE_DIRS "${NiftiCLib_INCLUDE_DIR}/nifti
") 226 if (NiftiCLib_LIBRARY) 227 set (NiftiCLib_LIB "${NiftiCLib_LIBRARY}
") 230 # ---------------------------------------------------------------------------- 231 # reset CMake variables 232 set (CMAKE_FIND_LIBRARY_SUFFIXES ${NiftiCLib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) 234 # ---------------------------------------------------------------------------- 235 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE 236 # if all listed variables are found or TRUE 237 include (FindPackageHandleStandardArgs) 239 find_package_handle_standard_args ( 242 NiftiCLib_INCLUDE_DIR 244 NiftiCLib_znz_LIBRARY 247 set (NiftiCLib_FOUND ${NIFTICLIB_FOUND}) 249 # ---------------------------------------------------------------------------- 251 if (NOT NiftiCLib_DIR AND NiftiCLib_FOUND) 252 string (REGEX REPLACE "include(/nifti)?/?
" "" NiftiCLib_PREFIX "${NiftiCLib_INCLUDE_DIR}
") 253 set (NiftiCLib_DIR "${NiftiCLib_PREFIX}
" CACHE PATH "Installation prefix
for NiftiCLib.
" FORCE) 254 unset (NiftiCLib_PREFIX) cmake NiftiCLib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
cmake NiftiCLib_INCLUDE_DIRS
cmake NiftiCLib_LIBRARIES
macro find_package()
Overloaded find_package() command.
cmake CMAKE_FIND_LIBRARY_SUFFIXES