FindMAGMA.cmake 15.6 KB
Newer Older
PRUVOST Florent's avatar
PRUVOST Florent committed
1
###
2 3
# WARNING: not maintained anymore
###
PRUVOST Florent's avatar
PRUVOST Florent committed
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
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
#                          of Tennessee Research Foundation.
#                          All rights reserved.
# @copyright (c) 2012-2016 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find MAGMA include dirs and libraries
# Use this module by invoking find_package with the form:
#  find_package(MAGMA
#               [REQUIRED]             # Fail with error if magma is not found
#               [COMPONENTS <comp1> <comp2> ...] # dependencies
#              )
#
#  MAGMA depends on the following libraries:
#   - CUDA/cuBLAS
#   - LAPACK
#   - CBLAS
#
#  COMPONENTS are optional libraries MAGMA could be linked with,
#  Use it to drive detection of a specific compilation chain
#  COMPONENTS can be some of the following:
#   - no components are available for now: maybe PLASMA in the future?
#
# Results are reported in variables:
#  MAGMA_FOUND            - True if headers and requested libraries were found
32
#  MAGMA_C_FLAGS          - list of required compilation flags (excluding -I)
PRUVOST Florent's avatar
PRUVOST Florent committed
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
#  MAGMA_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
#  MAGMA_INCLUDE_DIRS     - magma include directories
#  MAGMA_LIBRARY_DIRS     - Link directories for magma libraries
#  MAGMA_LIBRARIES        - magma libraries
#  MAGMA_INCLUDE_DIRS_DEP - magma + dependencies include directories
#  MAGMA_LIBRARY_DIRS_DEP - magma + dependencies link directories
#  MAGMA_LIBRARIES_DEP    - magma libraries + dependencies
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DMAGMA_DIR=path/to/magma):
#  MAGMA_DIR              - Where to find the base directory of magma
#  MAGMA_INCDIR           - Where to find the header files
#  MAGMA_LIBDIR           - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: MAGMA_DIR, MAGMA_INCDIR, MAGMA_LIBDIR
#
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012      Cedric Castagnede
# Copyright 2013-2016 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
#  License text for the above reference.)


if(NOT MAGMA_FOUND)
  set(MAGMA_DIR "" CACHE PATH "Installation directory of MAGMA library")
  if (NOT MAGMA_FIND_QUIETLY)
    message(STATUS "A cache variable, namely MAGMA_DIR, has been set to specify the install directory of MAGMA")
  endif()
endif(NOT MAGMA_FOUND)

# MAGMA depends on CUDA anyway, try to find it
75 76 77 78
if(MAGMA_FIND_REQUIRED)
  find_package(CUDA REQUIRED)
else()
  find_package(CUDA)
PRUVOST Florent's avatar
PRUVOST Florent committed
79
endif()
80
if( CUDA_FOUND )
81
  libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64")
82
endif ()
PRUVOST Florent's avatar
PRUVOST Florent committed
83 84 85 86 87 88 89 90
# MAGMA depends on cuBLAS which should come with CUDA, if not found -> error
if (NOT CUDA_CUBLAS_LIBRARIES)
  if(MAGMA_FIND_REQUIRED)
    message(FATAL_ERROR "Looking for MAGMA - MAGMA depends on cuBLAS which has "
      "not been found (should come with cuda install)")
  endif()
endif()
# MAGMA depends on LAPACK anyway, try to find it
91 92 93 94
if(MAGMA_FIND_REQUIRED)
  find_package(LAPACK REQUIRED)
else()
  find_package(LAPACK)
PRUVOST Florent's avatar
PRUVOST Florent committed
95 96
endif()
# MAGMA depends on CBLAS anyway, try to find it
97 98 99 100
if(MAGMA_FIND_REQUIRED)
  find_package(CBLAS REQUIRED)
else()
  find_package(CBLAS)
PRUVOST Florent's avatar
PRUVOST Florent committed
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
endif()

set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}")
set(ENV_MAGMA_INCDIR "$ENV{MAGMA_INCDIR}")
set(ENV_MAGMA_LIBDIR "$ENV{MAGMA_LIBDIR}")
set(MAGMA_GIVEN_BY_USER "FALSE")
if ( MAGMA_DIR OR ( MAGMA_INCDIR AND MAGMA_LIBDIR) OR ENV_MAGMA_DIR OR (ENV_MAGMA_INCDIR AND ENV_MAGMA_LIBDIR) )
  set(MAGMA_GIVEN_BY_USER "TRUE")
endif()

# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
# -------------------------------------------------------------------------------------
include(FindPkgConfig)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_EXECUTABLE AND NOT MAGMA_GIVEN_BY_USER)

  pkg_search_module(MAGMA magma)
  if (NOT MAGMA_FIND_QUIETLY)
    if (MAGMA_FOUND AND MAGMA_LIBRARIES)
      message(STATUS "Looking for MAGMA - found using PkgConfig")
      #if(NOT MAGMA_INCLUDE_DIRS)
      #    message("${Magenta}MAGMA_INCLUDE_DIRS is empty using PkgConfig."
      #        "Perhaps the path to magma headers is already present in your"
      #        "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}")
      #endif()
    else()
      message(STATUS "${Magenta}Looking for MAGMA - not found using PkgConfig. "
128 129
        "\n   Perhaps you should add the directory containing magma.pc "
        "\n   to the PKG_CONFIG_PATH environment variable.${ColourReset}")
PRUVOST Florent's avatar
PRUVOST Florent committed
130 131 132 133 134
    endif()
  endif()

  if (MAGMA_FIND_VERSION_EXACT)
    if( NOT (MAGMA_FIND_VERSION_MAJOR STREQUAL MAGMA_VERSION_MAJOR) OR
135
        NOT (MAGMA_FIND_VERSION_MINOR STREQUAL MAGMA_VERSION_MINOR) )
PRUVOST Florent's avatar
PRUVOST Florent committed
136
      if(NOT MAGMA_FIND_QUIETLY)
137 138 139
        message(FATAL_ERROR
          "MAGMA version found is ${MAGMA_VERSION_STRING} "
          "when required is ${MAGMA_FIND_VERSION}")
PRUVOST Florent's avatar
PRUVOST Florent committed
140 141 142 143 144
      endif()
    endif()
  else()
    # if the version found is older than the required then error
    if( (MAGMA_FIND_VERSION_MAJOR STRGREATER MAGMA_VERSION_MAJOR) OR
145
        (MAGMA_FIND_VERSION_MINOR STRGREATER MAGMA_VERSION_MINOR) )
PRUVOST Florent's avatar
PRUVOST Florent committed
146
      if(NOT MAGMA_FIND_QUIETLY)
147 148 149
        message(FATAL_ERROR
          "MAGMA version found is ${MAGMA_VERSION_STRING} "
          "when required is ${MAGMA_FIND_VERSION} or newer")
PRUVOST Florent's avatar
PRUVOST Florent committed
150 151 152 153 154 155 156 157 158 159 160 161
      endif()
    endif()
  endif()

  # if pkg-config is used: these variables are empty
  # the pkg_search_module call will set the following:
  # MAGMA_LDFLAGS: all required linker flags
  # MAGMA_CFLAGS:  all required cflags
  set(MAGMA_INCLUDE_DIRS_DEP "")
  set(MAGMA_LIBRARY_DIRS_DEP "")
  set(MAGMA_LIBRARIES_DEP "")
  # replace it anyway: we should update it with dependencies given by pkg-config
162 163 164
  set(MAGMA_INCLUDE_DIRS_DEP "${MAGMA_STATIC_INCLUDE_DIRS}")
  set(MAGMA_LIBRARY_DIRS_DEP "${MAGMA_STATIC_LIBRARY_DIRS}")
  set(MAGMA_LIBRARIES_DEP "${MAGMA_STATIC_LIBRARIES}")
165
  set(MAGMA_C_FLAGS "${MAGMA_CFLAGS_OTHER}")
PRUVOST Florent's avatar
PRUVOST Florent committed
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

endif(PKG_CONFIG_EXECUTABLE AND NOT MAGMA_GIVEN_BY_USER)

# if MAGMA is not found using pkg-config
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR (MAGMA_GIVEN_BY_USER) )

  if (NOT MAGMA_FIND_QUIETLY)
    message(STATUS "Looking for MAGMA - PkgConfig not used")
  endif()

  # Looking for include
  # -------------------

  # Add system include paths to search include
  # ------------------------------------------
  unset(_inc_env)
  set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}")
  set(ENV_MAGMA_INCDIR "$ENV{MAGMA_INCDIR}")
  if(ENV_MAGMA_INCDIR)
    list(APPEND _inc_env "${ENV_MAGMA_INCDIR}")
  elseif(ENV_MAGMA_DIR)
    list(APPEND _inc_env "${ENV_MAGMA_DIR}")
    list(APPEND _inc_env "${ENV_MAGMA_DIR}/include")
    list(APPEND _inc_env "${ENV_MAGMA_DIR}/include/magma")
  else()
    if(WIN32)
      string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
    else()
      string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
      list(APPEND _inc_env "${_path_env}")
      string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
      list(APPEND _inc_env "${_path_env}")
      string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
      list(APPEND _inc_env "${_path_env}")
      string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
      list(APPEND _inc_env "${_path_env}")
    endif()
  endif()
  list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
  list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
  list(REMOVE_DUPLICATES _inc_env)


  # Try to find the magma header in the given paths
  # -------------------------------------------------
  # call cmake macro to find the header path
  if(MAGMA_INCDIR)
    set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND")
    find_path(MAGMA_magma.h_DIRS
      NAMES magma.h
      HINTS ${MAGMA_INCDIR})
  else()
    if(MAGMA_DIR)
      set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND")
      find_path(MAGMA_magma.h_DIRS
221 222 223
        NAMES magma.h
        HINTS ${MAGMA_DIR}
        PATH_SUFFIXES "include" "include/magma")
PRUVOST Florent's avatar
PRUVOST Florent committed
224 225 226
    else()
      set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND")
      find_path(MAGMA_magma.h_DIRS
227 228
        NAMES magma.h
        HINTS ${_inc_env})
PRUVOST Florent's avatar
PRUVOST Florent committed
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
    endif()
  endif()
  mark_as_advanced(MAGMA_magma.h_DIRS)

  # If found, add path to cmake variable
  # ------------------------------------
  if (MAGMA_magma.h_DIRS)
    set(MAGMA_INCLUDE_DIRS "${MAGMA_magma.h_DIRS}")
  else ()
    set(MAGMA_INCLUDE_DIRS "MAGMA_INCLUDE_DIRS-NOTFOUND")
    if(NOT MAGMA_FIND_QUIETLY)
      message(STATUS "Looking for magma -- magma.h not found")
    endif()
  endif()


  # Looking for lib
  # ---------------

  # Add system library paths to search lib
  # --------------------------------------
  unset(_lib_env)
  set(ENV_MAGMA_LIBDIR "$ENV{MAGMA_LIBDIR}")
  if(ENV_MAGMA_LIBDIR)
    list(APPEND _lib_env "${ENV_MAGMA_LIBDIR}")
  elseif(ENV_MAGMA_DIR)
    list(APPEND _lib_env "${ENV_MAGMA_DIR}")
    list(APPEND _lib_env "${ENV_MAGMA_DIR}/lib")
  else()
    if(WIN32)
      string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
    else()
      if(APPLE)
262
        string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
PRUVOST Florent's avatar
PRUVOST Florent committed
263
      else()
264
        string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
PRUVOST Florent's avatar
PRUVOST Florent committed
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
      endif()
      list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
      list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
    endif()
  endif()
  list(REMOVE_DUPLICATES _lib_env)

  # Try to find the magma lib in the given paths
  # ----------------------------------------------

  # call cmake macro to find the lib path
  if(MAGMA_LIBDIR)
    set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND")
    find_library(MAGMA_magma_LIBRARY
      NAMES magma
      HINTS ${MAGMA_LIBDIR})
  else()
    if(MAGMA_DIR)
      set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND")
      find_library(MAGMA_magma_LIBRARY
285 286 287
        NAMES magma
        HINTS ${MAGMA_DIR}
        PATH_SUFFIXES lib lib32 lib64)
PRUVOST Florent's avatar
PRUVOST Florent committed
288 289 290
    else()
      set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND")
      find_library(MAGMA_magma_LIBRARY
291 292
        NAMES magma
        HINTS ${_lib_env})
PRUVOST Florent's avatar
PRUVOST Florent committed
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 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
    endif()
  endif()
  mark_as_advanced(MAGMA_magma_LIBRARY)

  # If found, add path to cmake variable
  # ------------------------------------
  if (MAGMA_magma_LIBRARY)
    get_filename_component(magma_lib_path "${MAGMA_magma_LIBRARY}" PATH)
    # set cmake variables
    set(MAGMA_LIBRARIES    "${MAGMA_magma_LIBRARY}")
    set(MAGMA_LIBRARY_DIRS "${magma_lib_path}")
  else ()
    set(MAGMA_LIBRARIES    "MAGMA_LIBRARIES-NOTFOUND")
    set(MAGMA_LIBRARY_DIRS "MAGMA_LIBRARY_DIRS-NOTFOUND")
    if(NOT MAGMA_FIND_QUIETLY)
      message(STATUS "Looking for magma -- lib magma not found")
    endif()
  endif ()

  # check a function to validate the find
  if (MAGMA_LIBRARIES)

    set(REQUIRED_LDFLAGS)
    set(REQUIRED_INCDIRS)
    set(REQUIRED_LIBDIRS)
    set(REQUIRED_LIBS)

    # MAGMA
    if (MAGMA_INCLUDE_DIRS)
      set(REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}")
    endif()
    if (MAGMA_LIBRARY_DIRS)
      set(REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}")
    endif()
    set(REQUIRED_LIBS "${MAGMA_LIBRARIES}")
    # CBLAS
    if (CBLAS_INCLUDE_DIRS_DEP)
      list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}")
    elseif (CBLAS_INCLUDE_DIRS)
      list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}")
    endif()
    if(CBLAS_LIBRARY_DIRS_DEP)
      list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}")
    elseif(CBLAS_LIBRARY_DIRS)
      list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}")
    endif()
    if (CBLAS_LIBRARIES_DEP)
      list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}")
    elseif(CBLAS_LIBRARIES)
      list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES}")
    endif()
    if (BLAS_LINKER_FLAGS)
      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
    endif()
    # LAPACK
    if (LAPACK_INCLUDE_DIRS)
      list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}")
    endif()
    if(LAPACK_LIBRARY_DIRS)
      list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}")
    endif()
    list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}")
    if (LAPACK_LINKER_FLAGS)
      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}")
    endif()
    # CUDA
    if (CUDA_INCLUDE_DIRS)
      list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}")
    endif()
    if(CUDA_LIBRARY_DIRS)
      list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}")
    endif()
    list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}")

    # set required libraries for link
    set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
    set(CMAKE_REQUIRED_LIBRARIES)
    list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
    foreach(lib_dir ${REQUIRED_LIBDIRS})
      list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
    endforeach()
    list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
    string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")

    # test link
    unset(MAGMA_WORKS CACHE)
    include(CheckFunctionExists)
    check_function_exists(magma_dgetrf MAGMA_WORKS)
    mark_as_advanced(MAGMA_WORKS)

    if(MAGMA_WORKS)
      # save link with dependencies
      set(MAGMA_LIBRARIES_DEP    "${REQUIRED_LIBS}")
      set(MAGMA_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
      set(MAGMA_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
      set(MAGMA_LINKER_FLAGS     "${REQUIRED_LDFLAGS}")
      list(REMOVE_DUPLICATES MAGMA_LIBRARY_DIRS_DEP)
      list(REMOVE_DUPLICATES MAGMA_INCLUDE_DIRS_DEP)
      list(REMOVE_DUPLICATES MAGMA_LINKER_FLAGS)
    else()
      if(NOT MAGMA_FIND_QUIETLY)
394 395 396 397 398
        message(STATUS "Looking for magma : test of magma_dgetrf with
                magma, cblas, cuda and lapack libraries fails")
        message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
        message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
        message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
PRUVOST Florent's avatar
PRUVOST Florent committed
399 400 401 402 403 404 405 406 407 408 409 410 411
      endif()
    endif()
    set(CMAKE_REQUIRED_INCLUDES)
    set(CMAKE_REQUIRED_FLAGS)
    set(CMAKE_REQUIRED_LIBRARIES)
  endif(MAGMA_LIBRARIES)

endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR (MAGMA_GIVEN_BY_USER) )

if (MAGMA_LIBRARIES)
  if (MAGMA_LIBRARY_DIRS)
    foreach(dir ${MAGMA_LIBRARY_DIRS})
      if ("${dir}" MATCHES "magma")
412
        set(first_lib_path "${dir}")
PRUVOST Florent's avatar
PRUVOST Florent committed
413 414 415 416 417
      endif()
    endforeach()
  else()
    list(GET MAGMA_LIBRARIES 0 first_lib)
    get_filename_component(first_lib_path "${first_lib}" PATH)
418
    set(MAGMA_LIBRARY_DIRS "${first_lib_path}")
PRUVOST Florent's avatar
PRUVOST Florent committed
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
  endif()
  if (${first_lib_path} MATCHES "/lib(32|64)?$")
    string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
    set(MAGMA_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of MAGMA library" FORCE)
  else()
    set(MAGMA_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of MAGMA library" FORCE)
  endif()
endif()
mark_as_advanced(MAGMA_DIR)
mark_as_advanced(MAGMA_DIR_FOUND)

# check that MAGMA has been found
# -------------------------------
include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND MAGMA_FOUND)
  find_package_handle_standard_args(MAGMA DEFAULT_MSG
    MAGMA_LIBRARIES)
else()
  find_package_handle_standard_args(MAGMA DEFAULT_MSG
    MAGMA_LIBRARIES
    MAGMA_WORKS)
endif()