2013-07-19 3 views
3

je suis venu avec le script FindMAGMA.cmake super simple suivante pour trouver la bibliothèque MAGMA donné il n'y a pas autour de:CMake find_library ne trouve pas la bibliothèque

# - Find the MAGMA library 
# 
# Usage: 
# find_package(MAGMA [REQUIRED] [QUIET]) 
# 
# It sets the following variables: 
# MAGMA_FOUND    ... true if magma is found on the system 
# MAGMA_LIBRARY_DIRS  ... full path to magma library 
# MAGMA_INCLUDE_DIRS  ... magma include directory 
# MAGMA_LIBRARIES   ... magma libraries 
# 
# The following variables will be checked by the function 
# MAGMA_USE_STATIC_LIBS  ... if true, only static libraries are found 
# MAGMA_ROOT    ... if set, the libraries are exclusively searched 
#         under this path 

#If environment variable MAGMA_ROOT is specified, it has same effect as MAGMA_ROOT 
if(NOT MAGMA_ROOT AND NOT $ENV{MAGMA_ROOT} STREQUAL "") 
    set(MAGMA_ROOT $ENV{MAGMA_ROOT}) 
    # set library directories 
    set(MAGMA_LIBRARY_DIRS ${MAGMA_ROOT}/lib) 
    # set include directories 
    set(MAGMA_INCLUDE_DIRS ${MAGMA_ROOT}/include) 
    # set libraries 
    find_library(
     MAGMA_LIBRARIES 
     NAMES "libmagma" 
     PATHS ${MAGMA_ROOT} 
     PATH_SUFFIXES "lib" 
     NO_DEFAULT_PATH 
    ) 
    set(MAGMA_FOUND TRUE) 
else() 
    set(MAGMA_FOUND FALSE) 
endif() 

Obtenir le comprennent et chemins lib est simple. Cependant, il ne trouve pas le fichier "libmagma.a" dans Ubuntu ou "libmagma.dylib" dans Mac OS X à moins que j'inclue l'extension mais cela va à l'encontre du but, n'est-ce pas? Quelqu'un peut-il s'il vous plaît aviser de ce que je fais mal ici?

Répondre

4

Retirez le premier lib du nom de la bibliothèque

find_library(
    MAGMA_LIBRARIES 
    NAMES magma 
    PATHS ${MAGMA_ROOT} 
    PATH_SUFFIXES lib 
    NO_DEFAULT_PATH 
) 

Aussi, jetez un oeil à FindPackageHandleStandardArgs qui peut vous aider à vous débarrasser de certains code boilerplate qui est habituellement nécessaire dans les scripts de trouver.

Questions connexes