1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
|
# Using FindCBLAS.cmake from the following repo
# https://github.com/clementfarabet/THC/blob/master/COPYRIGHT.txt
# - Find CBLAS library
#
# This module finds an installed fortran library that implements the CBLAS
# linear-algebra interface (see http://www.netlib.org/blas/), with CBLAS
# interface.
#
# This module sets the following variables:
# CBLAS_FOUND - set to true if a library implementing the CBLAS interface is found
# CBLAS_LIBRARIES - list of libraries (using full path name) to link against to use CBLAS
# CBLAS_INCLUDE_DIR - path to includes
# CBLAS_INCLUDE_FILE - the file to be included to use CBLAS
# MKL_BLAS_FOUND - set if MKL is found
SET(CBLAS_LIBRARIES CACHE STRING
"Path to CBLAS Library")
SET(CBLAS_INCLUDE_DIR CACHE STRING
"Path to CBLAS include directory")
SET(CBLAS_INCLUDE_FILE CACHE STRING
"CBLAS header name")
# If a valid PkgConfig configuration for cblas is found, this overrides and cancels
# all further checks.
FIND_PACKAGE(PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(PC_CBLAS cblas)
ENDIF(PKG_CONFIG_FOUND)
IF(PC_CBLAS_FOUND)
FOREACH(PC_LIB ${PC_CBLAS_LIBRARIES})
FIND_LIBRARY(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_CBLAS_LIBRARY_DIRS} )
IF (NOT ${PC_LIB}_LIBRARY)
message(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_CBLAS_LIBRARY_DIRS}")
ENDIF (NOT ${PC_LIB}_LIBRARY)
LIST(APPEND CBLAS_LIBRARIES ${${PC_LIB}_LIBRARY})
ENDFOREACH(PC_LIB)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CBLAS DEFAULT_MSG CBLAS_LIBRARIES)
MARK_AS_ADVANCED(CBLAS_LIBRARIES)
ELSE(PC_CBLAS_FOUND)
SET(INTEL_MKL_ROOT_DIR CACHE STRING
"Root directory of the Intel MKL")
SET(CBLAS_ROOT_DIR CACHE STRING
"Root directory for custom CBLAS implementation")
INCLUDE(CheckTypeSize)
CHECK_TYPE_SIZE("void*" SIZE_OF_VOIDP)
IF (NOT INTEL_MKL_ROOT_DIR)
SET(INTEL_MKL_ROOT_DIR $ENV{INTEL_MKL_ROOT})
ENDIF()
IF(NOT CBLAS_ROOT_DIR)
IF (ENV{CBLASDIR})
SET(CBLAS_ROOT_DIR $ENV{CBLASDIR})
IF ("${SIZE_OF_VOIDP}" EQUAL 8)
SET(CBLAS_LIB64_DIR "${CBLAS_ROOT_DIR}/lib64")
ELSE()
SET(CBLAS_LIB32_DIR "${CBLAS_ROOT_DIR}/lib")
ENDIF()
ENDIF()
IF (ENV{CBLAS_ROOT_DIR})
SET(CBLAS_ROOT_DIR $ENV{CBLAS_ROOT_DIR})
IF ("${SIZE_OF_VOIDP}" EQUAL 8)
SET(CBLAS_LIB64_DIR "${CBLAS_ROOT_DIR}/lib64")
ELSE()
SET(CBLAS_LIB32_DIR "${CBLAS_ROOT_DIR}/lib")
ENDIF()
ENDIF()
IF (INTEL_MKL_ROOT_DIR)
SET(CBLAS_ROOT_DIR ${INTEL_MKL_ROOT_DIR})
IF(APPLE)
IF ("${SIZE_OF_VOIDP}" EQUAL 8)
SET(CBLAS_LIB64_DIR "${CBLAS_ROOT_DIR}/lib")
ELSE()
SET(CBLAS_LIB32_DIR "${CBLAS_ROOT_DIR}/lib")
ENDIF()
ELSE(APPLE) # Windows and Linux
IF ("${SIZE_OF_VOIDP}" EQUAL 8)
SET(CBLAS_LIB64_DIR "${CBLAS_ROOT_DIR}/lib/intel64")
ELSE()
SET(CBLAS_LIB32_DIR "${CBLAS_ROOT_DIR}/lib/ia32")
ENDIF()
ENDIF(APPLE)
ENDIF()
SET(CBLAS_INCLUDE_DIR "${CBLAS_ROOT_DIR}/include")
ENDIF()
# Old CBLAS search
SET(_verbose TRUE)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckIncludeFile)
MACRO(CHECK_ALL_LIBRARIES
LIBRARIES
_prefix
_name
_flags
_list
_include
_search_include
_libraries_work_check)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the
# Check_Fortran_Function_Exists macro) whether can link against that library
# combination using the name of a routine given by _name using the linker
# flags given by _flags. If the combination of libraries is found and passes
# the link test, LIBRARIES is set to the list of complete library paths that
# have been found. Otherwise, LIBRARIES is set to FALSE.
# N.B. _prefix is the prefix applied to the names of all cached variables that
# are generated internally and marked advanced by this macro.
SET(__list)
FOREACH(_elem ${_list})
IF(__list)
SET(__list "${__list} - ${_elem}")
ELSE(__list)
SET(__list "${_elem}")
ENDIF(__list)
ENDFOREACH(_elem)
IF(_verbose)
MESSAGE(STATUS "Checking for [${__list}]")
ENDIF(_verbose)
SET(_libraries_work TRUE)
SET(${LIBRARIES})
SET(_combined_name)
SET(_paths)
FOREACH(_library ${_list})
SET(_combined_name ${_combined_name}_${_library})
# did we find all the libraries in the _list until now?
# (we stop at the first unfound one)
IF(_libraries_work)
IF(APPLE)
FIND_LIBRARY(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64
ENV DYLD_LIBRARY_PATH
"${CBLAS_LIB_DIR}" "${CBLAS_LIB32_DIR}" "${CBLAS_LIB64_DIR}"
)
ELSE(APPLE)
FIND_LIBRARY(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64
ENV LD_LIBRARY_PATH
"${CBLAS_LIB_DIR}" "${CBLAS_LIB32_DIR}" "${CBLAS_LIB64_DIR}"
PATH_SUFFIXES atlas
)
IF(NOT ${_prefix}_${library}_LIBRARY)
LIST(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".so.3")
FIND_LIBRARY(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64
ENV LD_LIBRARY_PATH
"${CBLAS_LIB_DIR}" "${CBLAS_LIB32_DIR}" "${CBLAS_LIB64_DIR}"
PATH_SUFFIXES atlas
)
ENDIF(NOT ${_prefix}_${library}_LIBRARY)
ENDIF(APPLE)
MARK_AS_ADVANCED(${_prefix}_${_library}_LIBRARY)
SET(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
SET(_libraries_work ${${_prefix}_${_library}_LIBRARY})
ENDIF(_libraries_work)
ENDFOREACH(_library)
# Test include
SET(_bug_search_include ${_search_include}) #CMAKE BUG!!! SHOULD NOT BE THAT
SET(_bug_libraries_work_check ${_libraries_work_check}) #CMAKE BUG!!! SHOULD NOT BE THAT
IF(_bug_search_include)
FIND_PATH(${_prefix}${_combined_name}_INCLUDE ${_include}
/opt/intel/mkl/include
/usr/include
/usr/local/include
/sw/include
/opt/local/include
PATH_SUFFIXES
openblas
)
MARK_AS_ADVANCED(${_prefix}${_combined_name}_INCLUDE)
IF(${_prefix}${_combined_name}_INCLUDE)
IF (_verbose)
MESSAGE(STATUS "Includes found")
ENDIF (_verbose)
SET(${_prefix}_INCLUDE_DIR ${${_prefix}${_combined_name}_INCLUDE})
SET(${_prefix}_INCLUDE_FILE ${_include})
ELSE(${_prefix}${_combined_name}_INCLUDE)
SET(_libraries_work FALSE)
ENDIF(${_prefix}${_combined_name}_INCLUDE)
ELSE(_bug_search_include)
SET(${_prefix}_INCLUDE_DIR)
SET(${_prefix}_INCLUDE_FILE ${_include})
ENDIF(_bug_search_include)
IF (_bug_libraries_work_check)
# Test this combination of libraries.
IF(_libraries_work)
SET(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}})
CHECK_FUNCTION_EXISTS(${_name} ${_prefix}${_combined_name}_WORKS)
SET(CMAKE_REQUIRED_LIBRARIES)
MARK_AS_ADVANCED(${_prefix}${_combined_name}_WORKS)
SET(_libraries_work ${${_prefix}${_combined_name}_WORKS})
IF(_verbose AND _libraries_work)
MESSAGE(STATUS "CBLAS Symbols FOUND")
ELSE()
MESSAGE(STATUS "CBLAS Symbols NOTFOUND")
ENDIF(_verbose AND _libraries_work)
ENDIF(_libraries_work)
ENDIF()
# Fin
IF(NOT _libraries_work)
SET(${LIBRARIES} NOTFOUND)
ENDIF(NOT _libraries_work)
ENDMACRO(CHECK_ALL_LIBRARIES)
# MKL CBLAS library?
IF(NOT CBLAS_LIBRARIES)
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"mkl_rt"
"mkl_cblas.h"
FALSE,
TRUE)
ENDIF(NOT CBLAS_LIBRARIES)
IF(CBLAS_LIBRARIES)
SET(MKL_FOUND ON)
ENDIF()
# Apple CBLAS library?
IF(NOT CBLAS_LIBRARIES)
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"Accelerate"
"Accelerate/Accelerate.h"
FALSE,
TRUE)
ENDIF(NOT CBLAS_LIBRARIES)
IF( NOT CBLAS_LIBRARIES )
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"vecLib"
"vecLib/vecLib.h"
FALSE,
TRUE)
ENDIF( NOT CBLAS_LIBRARIES )
# CBLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
IF(NOT CBLAS_LIBRARIES)
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"cblas;atlas"
"cblas.h"
TRUE,
TRUE)
ENDIF(NOT CBLAS_LIBRARIES)
# OpenBLAS library
IF(NOT CBLAS_LIBRARIES)
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"openblas"
"cblas.h"
TRUE,
TRUE)
ENDIF(NOT CBLAS_LIBRARIES)
# Generic CBLAS library
IF(NOT CBLAS_LIBRARIES)
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"cblas"
"cblas.h"
TRUE,
TRUE)
ENDIF(NOT CBLAS_LIBRARIES)
# Generic BLAS+CBLAS library
# Debian based systems have them as single library
IF(NOT CBLAS_LIBRARIES)
CHECK_ALL_LIBRARIES(
CBLAS_LIBRARIES
CBLAS
cblas_dgemm
""
"blas"
"cblas.h"
TRUE,
TRUE)
ENDIF(NOT CBLAS_LIBRARIES)
IF(CBLAS_LIBRARIES)
IF (NOT MKL_CBLAS_FOUND)
SET(CBLAS_FOUND TRUE)
ENDIF()
ELSE(CBLAS_LIBRARIES)
SET(CBLAS_FOUND FALSE)
ENDIF(CBLAS_LIBRARIES)
IF(NOT CBLAS_FOUND AND CBLAS_FIND_REQUIRED)
IF(NOT MKL_CBLAS_FOUND)
MESSAGE(FATAL_ERROR "CBLAS library not found. Please specify library location")
ENDIF()
ENDIF(NOT CBLAS_FOUND AND CBLAS_FIND_REQUIRED)
IF(NOT CBLAS_FIND_QUIETLY)
IF(CBLAS_FOUND OR MKL_CBLAS_FOUND)
MESSAGE(STATUS "CBLAS library found")
ELSE()
MESSAGE(STATUS "CBLAS library not found.")
ENDIF()
ENDIF(NOT CBLAS_FIND_QUIETLY)
ENDIF(PC_CBLAS_FOUND)
|