]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/include/Modules/FindGSL.cmake
ManualPaint RangeSlider 50% DFCH
[creaMaracasVisu.git] / lib / maracasVisuLib / include / Modules / FindGSL.cmake
1 #
2 # This module finds if GSL is installed and determines where the
3 # include files and libraries are. It also determines what the name of
4 # the library is. This code sets the following variables:
5 #
6 #  GSL_FOUND        = system has GSL and it should be used
7 #  GSL_LIBRARIES         = full path to the GSL library and linker flags on unix
8 #  CMAKE_GSL_CXX_FLAGS        = compiler flags for building GSL 
9 #  GSL_INCLUDE_DIR    = include path of GSL
10
11 IF(WIN32)
12   IF(CYGWIN)
13
14     FIND_PROGRAM(CMAKE_GSL_CONFIG gsl-config ../GSL/bin ../../GSL/bin)
15     SET(CMAKE_GSL_CXX_FLAGS "`${CMAKE_GSL_CONFIG} --cflags`")
16     SET(GSL_LIBRARIES "`${CMAKE_GSL_CONFIG} --libs`")
17
18   ELSE(CYGWIN)
19
20     SET (GSL_POSSIBLE_LIB_PATHS
21       $ENV{GSL}/lib
22       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GNU Scientific Library_is1;Inno Setup: App Path]/lib"
23     )
24
25     FIND_LIBRARY(GSL_STATIC_LIBRARY
26       NAMES gsl
27       PATHS ${GSL_POSSIBLE_LIB_PATHS} 
28     )
29
30     FIND_LIBRARY(GSL_SHARED_LIBRARY
31       NAMES gsl
32       PATHS ${GSL_POSSIBLE_LIB_PATHS} 
33     )
34
35     SET (GSL_POSSIBLE_INCLUDE_PATHS
36       $ENV{GSL}/include
37       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GNU Scientific Library_is1;Inno Setup: App Path]/include"
38     )
39
40     FIND_PATH(GSL_INCLUDE_DIR
41       gsl/gsl_version.h
42       ${GSL_POSSIBLE_INCLUDE_PATHS} 
43     )
44
45     IF(GSL_SHARED_LIBRARY)
46       OPTION(GSL_USE_SHARED_LIBS 
47              "Use shared versions of GSL libraries" ON)
48       MARK_AS_ADVANCED(GSL_USE_SHARED_LIBS)
49     ENDIF(GSL_SHARED_LIBRARY)
50
51     SET(CMAKE_GSL_LIBRARIES ${CMAKE_GSL_LIBRARIES}) # comctl32 ctl3d32 wsock32 rpcrt4)
52
53     IF(GSL_USE_SHARED_LIBS)
54       SET(GSL_LIBRARIES ${GSL_SHARED_LIBRARY} ${CMAKE_GSL_LIBRARIES})
55     ELSE(GSL_USE_SHARED_LIBS)
56       SET(GSL_LIBRARIES ${GSL_STATIC_LIBRARY} ${CMAKE_GSL_LIBRARIES})
57     ENDIF(GSL_USE_SHARED_LIBS)
58
59     MARK_AS_ADVANCED(
60       GSL_STATIC_LIBRARY
61       GSL_SHARED_LIBRARY
62       GSL_INCLUDE_DIR
63     )
64   ENDIF(CYGWIN)
65 ELSE(WIN32)
66
67   FIND_PROGRAM(CMAKE_GSL_CONFIG gsl-config ../GSL/bin ../../GSL/bin)
68   SET(CMAKE_GSL_CXX_FLAGS "`${CMAKE_GSL_CONFIG} --cflags`")
69   SET(GSL_LIBRARIES "`${CMAKE_GSL_CONFIG} --libs`")
70
71 ENDIF(WIN32)  
72
73 MARK_AS_ADVANCED(
74   CMAKE_GSL_CONFIG 
75   CMAKE_GSL_CXX_FLAGS
76   GSL_INCLUDE_DIR
77 )
78
79 IF(GSL_LIBRARIES)
80   IF(GSL_INCLUDE_DIR OR CMAKE_GSL_CXX_FLAGS)
81     SET(CMAKE_GSL_CAN_COMPILE 1)
82     SET(GSL_FOUND 1)
83   ENDIF(GSL_INCLUDE_DIR OR CMAKE_GSL_CXX_FLAGS)
84 ENDIF(GSL_LIBRARIES)
85