source: pacpussensors/trunk/Vislab/lib3dv-1.2.0/lib3dv/eigen/cmake/FindGSL.cmake

Last change on this file was 136, checked in by ldecherf, 8 years ago

Doc

File size: 4.9 KB
Line 
1# Try to find gnu scientific library GSL
2# See
3# http://www.gnu.org/software/gsl/ and
4# http://gnuwin32.sourceforge.net/packages/gsl.htm
5#
6# Once run this will define:
7#
8# GSL_FOUND = system has GSL lib
9#
10# GSL_LIBRARIES = full path to the libraries
11# on Unix/Linux with additional linker flags from "gsl-config --libs"
12#
13# CMAKE_GSL_CXX_FLAGS = Unix compiler flags for GSL, essentially "`gsl-config --cxxflags`"
14#
15# GSL_INCLUDE_DIR = where to find headers
16#
17# GSL_LINK_DIRECTORIES = link directories, useful for rpath on Unix
18# GSL_EXE_LINKER_FLAGS = rpath on Unix
19#
20# Felix Woelk 07/2004
21# Jan Woetzel
22#
23# www.mip.informatik.uni-kiel.de
24# --------------------------------
25
26IF(WIN32)
27 # JW tested with gsl-1.8, Windows XP, MSVS 7.1
28 SET(GSL_POSSIBLE_ROOT_DIRS
29 ${GSL_ROOT_DIR}
30 $ENV{GSL_ROOT_DIR}
31 ${GSL_DIR}
32 ${GSL_HOME}
33 $ENV{GSL_DIR}
34 $ENV{GSL_HOME}
35 $ENV{EXTRA}
36 "C:/Program Files/GnuWin32"
37 )
38 FIND_PATH(GSL_INCLUDE_DIR
39 NAMES gsl/gsl_cdf.h gsl/gsl_randist.h
40 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
41 PATH_SUFFIXES include
42 DOC "GSL header include dir"
43 )
44
45 FIND_LIBRARY(GSL_GSL_LIBRARY
46 NAMES libgsl.dll.a gsl libgsl
47 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
48 PATH_SUFFIXES lib
49 DOC "GSL library" )
50
51 if(NOT GSL_GSL_LIBRARY)
52 FIND_FILE(GSL_GSL_LIBRARY
53 NAMES libgsl.dll.a
54 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
55 PATH_SUFFIXES lib
56 DOC "GSL library")
57 endif(NOT GSL_GSL_LIBRARY)
58
59 FIND_LIBRARY(GSL_GSLCBLAS_LIBRARY
60 NAMES libgslcblas.dll.a gslcblas libgslcblas
61 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
62 PATH_SUFFIXES lib
63 DOC "GSL cblas library dir" )
64
65 if(NOT GSL_GSLCBLAS_LIBRARY)
66 FIND_FILE(GSL_GSLCBLAS_LIBRARY
67 NAMES libgslcblas.dll.a
68 PATHS ${GSL_POSSIBLE_ROOT_DIRS}
69 PATH_SUFFIXES lib
70 DOC "GSL library")
71 endif(NOT GSL_GSLCBLAS_LIBRARY)
72
73 SET(GSL_LIBRARIES ${GSL_GSL_LIBRARY})
74
75 #MESSAGE("DBG\n"
76 # "GSL_GSL_LIBRARY=${GSL_GSL_LIBRARY}\n"
77 # "GSL_GSLCBLAS_LIBRARY=${GSL_GSLCBLAS_LIBRARY}\n"
78 # "GSL_LIBRARIES=${GSL_LIBRARIES}")
79
80
81ELSE(WIN32)
82
83 IF(UNIX)
84 SET(GSL_CONFIG_PREFER_PATH
85 "$ENV{GSL_DIR}/bin"
86 "$ENV{GSL_DIR}"
87 "$ENV{GSL_HOME}/bin"
88 "$ENV{GSL_HOME}"
89 CACHE STRING "preferred path to GSL (gsl-config)")
90 FIND_PROGRAM(GSL_CONFIG gsl-config
91 ${GSL_CONFIG_PREFER_PATH}
92 /usr/bin/
93 )
94 # MESSAGE("DBG GSL_CONFIG ${GSL_CONFIG}")
95
96 IF (GSL_CONFIG)
97 # set CXXFLAGS to be fed into CXX_FLAGS by the user:
98 SET(GSL_CXX_FLAGS "`${GSL_CONFIG} --cflags`")
99
100 # set INCLUDE_DIRS to prefix+include
101 EXEC_PROGRAM(${GSL_CONFIG}
102 ARGS --prefix
103 OUTPUT_VARIABLE GSL_PREFIX)
104 SET(GSL_INCLUDE_DIR ${GSL_PREFIX}/include CACHE STRING INTERNAL)
105
106 # set link libraries and link flags
107 #SET(GSL_LIBRARIES "`${GSL_CONFIG} --libs`")
108 EXEC_PROGRAM(${GSL_CONFIG}
109 ARGS --libs
110 OUTPUT_VARIABLE GSL_LIBRARIES )
111
112 # extract link dirs for rpath
113 EXEC_PROGRAM(${GSL_CONFIG}
114 ARGS --libs
115 OUTPUT_VARIABLE GSL_CONFIG_LIBS )
116
117 # extract version
118 EXEC_PROGRAM(${GSL_CONFIG}
119 ARGS --version
120 OUTPUT_VARIABLE GSL_FULL_VERSION )
121
122 # split version as major/minor
123 STRING(REGEX MATCH "(.)\\..*" GSL_VERSION_MAJOR_ "${GSL_FULL_VERSION}")
124 SET(GSL_VERSION_MAJOR ${CMAKE_MATCH_1})
125 STRING(REGEX MATCH ".\\.(.*)" GSL_VERSION_MINOR_ "${GSL_FULL_VERSION}")
126 SET(GSL_VERSION_MINOR ${CMAKE_MATCH_1})
127
128 # split off the link dirs (for rpath)
129 # use regular expression to match wildcard equivalent "-L*<endchar>"
130 # with <endchar> is a space or a semicolon
131 STRING(REGEX MATCHALL "[-][L]([^ ;])+"
132 GSL_LINK_DIRECTORIES_WITH_PREFIX
133 "${GSL_CONFIG_LIBS}" )
134 # MESSAGE("DBG GSL_LINK_DIRECTORIES_WITH_PREFIX=${GSL_LINK_DIRECTORIES_WITH_PREFIX}")
135
136 # remove prefix -L because we need the pure directory for LINK_DIRECTORIES
137
138 IF (GSL_LINK_DIRECTORIES_WITH_PREFIX)
139 STRING(REGEX REPLACE "[-][L]" "" GSL_LINK_DIRECTORIES ${GSL_LINK_DIRECTORIES_WITH_PREFIX} )
140 ENDIF (GSL_LINK_DIRECTORIES_WITH_PREFIX)
141 SET(GSL_EXE_LINKER_FLAGS "-Wl,-rpath,${GSL_LINK_DIRECTORIES}" CACHE STRING INTERNAL)
142 # MESSAGE("DBG GSL_LINK_DIRECTORIES=${GSL_LINK_DIRECTORIES}")
143 # MESSAGE("DBG GSL_EXE_LINKER_FLAGS=${GSL_EXE_LINKER_FLAGS}")
144
145 # ADD_DEFINITIONS("-DHAVE_GSL")
146 # SET(GSL_DEFINITIONS "-DHAVE_GSL")
147 MARK_AS_ADVANCED(
148 GSL_CXX_FLAGS
149 GSL_INCLUDE_DIR
150 GSL_LIBRARIES
151 GSL_LINK_DIRECTORIES
152 GSL_DEFINITIONS
153 )
154 MESSAGE(STATUS "Using GSL from ${GSL_PREFIX}")
155
156 ELSE(GSL_CONFIG)
157 MESSAGE("FindGSL.cmake: gsl-config not found. Please set it manually. GSL_CONFIG=${GSL_CONFIG}")
158 ENDIF(GSL_CONFIG)
159
160 ENDIF(UNIX)
161ENDIF(WIN32)
162
163
164IF(GSL_LIBRARIES)
165 IF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)
166
167 SET(GSL_FOUND 1)
168
169 ENDIF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)
170ENDIF(GSL_LIBRARIES)
Note: See TracBrowser for help on using the repository browser.