FindSUITESPARSE.cmake 4.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# - Try to find SUITESPARSE
# Once done this will define
#  
#  SUITESPARSE_FOUND        - system has SUITESPARSE
#  SUITESPARSE_INCLUDE_DIRS - the SUITESPARSE include directory
#  SUITESPARSE_LIBRARIES    - Link these to use SUITESPARSE
#  SUITESPARSE_LIBRARY_DIR  - Library directory containing suitesparse libs
#   

IF (SUITESPARSE_INCLUDE_DIRS)
  # Already in cache, be silent
  SET(SUITESPARSE_FIND_QUIETLY TRUE)
ENDIF (SUITESPARSE_INCLUDE_DIRS)

if( WIN32 )
   # Find cholmod part of the suitesparse library collection

   FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
19
              PATHS "C:\\libs\\win32\\SuiteSparse\\Include"  )
20
21
22
23
24
25
26
27
28

   # Add cholmod include directory to collection include directories
   IF ( CHOLMOD_INCLUDE_DIR )
	list ( APPEND SUITESPARSE_INCLUDE_DIRS ${CHOLMOD_INCLUDE_DIR} )
   ENDIF( CHOLMOD_INCLUDE_DIR )


   # find path suitesparse library
   FIND_PATH( SUITESPARSE_LIBRARY_DIRS 
29
30
	         amd.lib
               PATHS "C:\\libs\\win32\\SuiteSparse\\libs" )
31
32
33

   # if we found the library, add it to the defined libraries
   IF ( SUITESPARSE_LIBRARY_DIRS )
34
	list ( APPEND SUITESPARSE_LIBRARIES optimized;amd;optimized;camd;optimized;ccolamd;optimized;cholmod;optimized;colamd;optimized;metis;optimized;spqr;optimized;umfpack;debug;amdd;debug;camdd;debug;ccolamdd;debug;cholmodd;debug;spqrd;debug;umfpackd;debug;colamdd;debug;metisd;optimized;blas;optimized;libf2c;optimized;lapack;debug;blasd;debug;libf2cd;debug;lapackd )
35
36
37
   ENDIF( SUITESPARSE_LIBRARY_DIRS )  

else( WIN32 )
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
   IF( APPLE)
	   FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
        	      PATHS  /opt/local/include/ufsparse )

           FIND_PATH( SUITESPARSE_LIBRARY_DIR
                      NAMES libcholmod.a 
                      PATHS /opt/local/lib )

	  

   ELSE(APPLE)
	   FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
        	      PATHS /usr/local/include /usr/include /usr/include/suitesparse/ ${CMAKE_SOURCE_DIR}/MacOS/Libs/cholmod
              	      PATH_SUFFIXES cholmod/ CHOLMOD/ )

   	
           FIND_PATH( SUITESPARSE_LIBRARY_DIR
                      NAMES libcholmod.so 
                      PATHS /usr/lib /usr/local/lib )


   ENDIF(APPLE)
60
61
62
63
64
65
66
67
68
69
70
71
72

   # Add cholmod include directory to collection include directories
   IF ( CHOLMOD_INCLUDE_DIR )
	list ( APPEND SUITESPARSE_INCLUDE_DIRS ${CHOLMOD_INCLUDE_DIR} )
   ENDIF( CHOLMOD_INCLUDE_DIR )


   # if we found the library, add it to the defined libraries
   IF ( SUITESPARSE_LIBRARY_DIR )
       list ( APPEND SUITESPARSE_LIBRARY_DIRS ${SUITESPARSE_LIBRARY_DIR} )
       FIND_LIBRARY( CHOLMOD_LIBRARY
                     NAMES cholmod CHOLMOD
                     PATHS ${SUITESPARSE_LIBRARY_DIR} )
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
       FIND_LIBRARY( UMFPACK_LIBRARY
                     NAMES umfpack UMFPACK
                     PATHS ${SUITESPARSE_LIBRARY_DIR} )

	IF(APPLE)
		list ( APPEND SUITESPARSE_LIBRARIES ${SUITESPARSE_LIBRARY_DIR}/libamd.a 
                                                    ${SUITESPARSE_LIBRARY_DIR}/libbtf.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libcamd.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libccolamd.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libcolamd.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libcsparse.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libcxsparse.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libklu.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libspqr.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libumfpack.a
                                                    ${SUITESPARSE_LIBRARY_DIR}/libmetis.a
			)
	ENDIF(APPLE)


	list ( APPEND SUITESPARSE_LIBRARIES ${CHOLMOD_LIBRARY} ${UMFPACK_LIBRARY} )
94
95
96
97
98
99
100
101
102
103
104
105
106
107
   ENDIF( SUITESPARSE_LIBRARY_DIR )  
   
endif( WIN32 )


IF (SUITESPARSE_INCLUDE_DIRS AND SUITESPARSE_LIBRARIES)
   IF(WIN32)
    list (APPEND SUITESPARSE_INCLUDE_DIRS ${CHOLMOD_INCLUDE_DIR}/../../UFconfig )
   ENDIF(WIN32)
   SET(SUITESPARSE_FOUND TRUE)
ELSE (SUITESPARSE_INCLUDE_DIRS AND SUITESPARSE_LIBRARIES)
   SET( SUITESPARSE_FOUND FALSE )
ENDIF (SUITESPARSE_INCLUDE_DIRS AND SUITESPARSE_LIBRARIES)