tFindGSL.cmake - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch) (HTM) git clone git://src.adamsgaard.dk/pism (DIR) Log (DIR) Files (DIR) Refs (DIR) LICENSE --- tFindGSL.cmake (2160B) --- 1 # - Find GSL 2 # Find the native GSL includes and library 3 # 4 # GSL_INCLUDES - where to find gsl/gsl_*.h, etc. 5 # GSL_LIBRARIES - List of libraries when using GSL. 6 # GSL_FOUND - True if GSL found. 7 8 9 if (GSL_INCLUDES) 10 # Already in cache, be silent 11 set (GSL_FIND_QUIETLY TRUE) 12 endif (GSL_INCLUDES) 13 14 find_path (GSL_INCLUDES gsl/gsl_math.h 15 HINTS "${GSL_ROOT}/include" "$ENV{GSL_ROOT}/include") 16 17 string(REGEX REPLACE "/include/?$" "/lib" 18 GSL_LIB_HINT ${GSL_INCLUDES}) 19 20 find_library (GSL_LIB 21 NAMES gsl 22 HINTS ${GSL_LIB_HINT}) 23 24 find_library(GSL_CBLAS_LIB 25 NAMES gslcblas 26 HINTS ${GSL_LIB_HINT}) 27 28 if ((NOT GSL_INCLUDES) OR (NOT GSL_LIB) OR (NOT GSL_CBLAS_LIB)) 29 message(STATUS "Trying to find GSL using 'gsl-config'...") 30 find_program(GSL_CONFIG "gsl-config") 31 if (GSL_CONFIG) 32 execute_process(COMMAND ${GSL_CONFIG} --prefix 33 OUTPUT_VARIABLE GSL_PREFIX 34 OUTPUT_STRIP_TRAILING_WHITESPACE) 35 36 find_path(GSL_INCLUDES gsl/gsl_math.h 37 HINTS "${GSL_PREFIX}/include") 38 39 find_library (GSL_LIB NAMES gsl 40 HINTS "${GSL_PREFIX}/lib") 41 42 find_library(GSL_CBLAS_LIB NAMES gslcblas 43 HINTS "${GSL_PREFIX}/lib") 44 endif() 45 endif() 46 47 if ((NOT GSL_LIB) OR (NOT GSL_INCLUDES)) 48 message(STATUS "Trying to find GSL using LD_LIBRARY_PATH (we're desperate)...") 49 50 file(TO_CMAKE_PATH "$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH) 51 52 find_library(GSL_LIB 53 NAMES gsl 54 HINTS ${LD_LIBRARY_PATH}) 55 56 find_library(GSL_CBLAS_LIB 57 NAMES gslcblas 58 HINTS ${LD_LIBRARY_PATH}) 59 60 if (GSL_LIB) 61 get_filename_component(GSL_LIB_DIR ${GSL_LIB} PATH) 62 string(REGEX REPLACE "/lib/?$" "/include" 63 GSL_H_HINT ${GSL_LIB_DIR}) 64 65 find_path (GSL_INCLUDES gsl/gsl_math.h 66 HINTS ${GSL_H_HINT} 67 DOC "Path to gsl/gsl_math.h") 68 endif() 69 endif() 70 71 if (GSL_LIB AND GSL_CBLAS_LIB) 72 set (GSL_LIBRARIES "${GSL_LIB}" "${GSL_CBLAS_LIB}") 73 endif() 74 75 # handle the QUIETLY and REQUIRED arguments and set GSL_FOUND to TRUE if 76 # all listed variables are TRUE 77 include (FindPackageHandleStandardArgs) 78 find_package_handle_standard_args (GSL DEFAULT_MSG GSL_LIBRARIES GSL_INCLUDES) 79 80 mark_as_advanced (GSL_LIB GSL_CBLAS_LIB GSL_INCLUDES GSL_CONFIG)