2
2
FindGraphBLAS
3
3
--------
4
4
5
+ The following copyright and license applies to just this file only, not to
6
+ the GraphBLAS library itself:
5
7
LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
6
8
SPDX-License-Identifier: BSD-2-Clause
7
9
See additional acknowledgments in the LICENSE file,
@@ -23,7 +25,8 @@ This module defines the following variables:
23
25
::
24
26
25
27
GRAPHBLAS_INCLUDE_DIR - where to find GraphBLAS.h, etc.
26
- GRAPHBLAS_LIBRARY - GraphBLAS library
28
+ GRAPHBLAS_LIBRARY - dynamic GraphBLAS library
29
+ GRAPHBLAS_STATIC - static GraphBLAS library
27
30
GRAPHBLAS_LIBRARIES - List of libraries when using GraphBLAS.
28
31
GRAPHBLAS_FOUND - True if GraphBLAS found.
29
32
@@ -32,8 +35,8 @@ This module defines the following variables:
32
35
Hints
33
36
^^^^^
34
37
35
- A user may set ``GRAPHBLAS_ROOT`` to a GraphBLAS installation root to tell this
36
- module where to look.
38
+ A user may set ``GRAPHBLAS_ROOT`` or ``GraphBLAS_ROOT`` to a GraphBLAS
39
+ installation root to tell this module where to look.
37
40
38
41
Otherwise, the first place searched is in ../GraphBLAS, relative to the LAGraph
39
42
source directory. That is, if GraphBLAS and LAGraph reside in the same parent
@@ -43,44 +46,96 @@ This takes precedence over the system-wide installation of GraphBLAS, which
43
46
might be an older version. This method gives the user the ability to compile
44
47
LAGraph with their own copy of GraphBLAS, ignoring the system-wide version.
45
48
49
+ If SuiteSparse:GraphBLAS is the GraphBLAS library being utilized,
50
+ all the Find*.cmake files in SuiteSparse are installed by 'make install' into
51
+ /usr/local/lib/cmake/SuiteSparse (where '/usr/local' is the
52
+ ${CMAKE_INSTALL_PREFIX}). To access this file, place the following commands
53
+ in your CMakeLists.txt file. See also SuiteSparse/Example/CMakeLists.txt:
54
+
55
+ set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
56
+ ${CMAKE_INSTALL_PREFIX}/lib/cmake/SuiteSparse )
57
+
46
58
#]=======================================================================]
47
59
48
60
# NB: this is built around assumptions about one particular GraphBLAS
49
61
# installation (SuiteSparse:GraphBLAS). As other installations become available
50
62
# changes to this will likely be required.
51
63
52
64
# "Include" for SuiteSparse:GraphBLAS
53
- find_path (
54
- GRAPHBLAS_INCLUDE_DIR
65
+ find_path ( GRAPHBLAS_INCLUDE_DIR
55
66
NAMES GraphBLAS.h
67
+ HINTS ${GRAPHBLAS_ROOT}
68
+ HINTS ENV GRAPHBLAS_ROOT
56
69
HINTS ${CMAKE_SOURCE_DIR} /..
57
70
HINTS ${CMAKE_SOURCE_DIR} /../GraphBLAS
58
71
HINTS ${CMAKE_SOURCE_DIR} /../SuiteSparse/GraphBLAS
59
- PATHS GRAPHBLAS_ROOT ENV GRAPHBLAS_ROOT
60
72
PATH_SUFFIXES include Include
61
73
)
62
74
63
- # "build" for SuiteSparse:GraphBLAS
64
- find_library (
65
- GRAPHBLAS_LIBRARY
75
+ # dynamic SuiteSparse:GraphBLAS library
76
+ find_library ( GRAPHBLAS_LIBRARY
66
77
NAMES graphblas
78
+ HINTS ${GRAPHBLAS_ROOT}
79
+ HINTS ENV GRAPHBLAS_ROOT
67
80
HINTS ${CMAKE_SOURCE_DIR} /..
68
81
HINTS ${CMAKE_SOURCE_DIR} /../GraphBLAS
69
82
HINTS ${CMAKE_SOURCE_DIR} /../SuiteSparse/GraphBLAS
70
- PATHS GRAPHBLAS_ROOT ENV GRAPHBLAS_ROOT
71
83
PATH_SUFFIXES lib build alternative
72
84
)
73
85
74
- # get version of .so using REALPATH
75
- get_filename_component (GRAPHBLAS_LIBRARY ${GRAPHBLAS_LIBRARY} REALPATH)
76
- string (
77
- REGEX MATCH "[0-9]+.[0-9]+.[0-9]+"
78
- GRAPHBLAS_VERSION
79
- ${GRAPHBLAS_LIBRARY}
86
+ if ( MSVC )
87
+ set ( STATIC_SUFFIX .lib )
88
+ set ( STATIC_NAME graphblas_static )
89
+ else ( )
90
+ set ( STATIC_SUFFIX .a )
91
+ set ( STATIC_NAME graphblas )
92
+ endif ( )
93
+
94
+ # static SuiteSparse:GraphBLAS library
95
+ set ( save ${CMAKE_FIND_LIBRARY_SUFFIXES} )
96
+ set ( CMAKE_FIND_LIBRARY_SUFFIXES ${STATIC_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES} )
97
+ find_library ( GRAPHBLAS_STATIC
98
+ NAMES ${STATIC_NAME}
99
+ HINTS ${GRAPHBLAS_ROOT}
100
+ HINTS ENV GRAPHBLAS_ROOT
101
+ HINTS ${CMAKE_SOURCE_DIR} /..
102
+ HINTS ${CMAKE_SOURCE_DIR} /../GraphBLAS
103
+ HINTS ${CMAKE_SOURCE_DIR} /../SuiteSparse/GraphBLAS
104
+ PATH_SUFFIXES lib build alternative
105
+ )
106
+ set ( CMAKE_FIND_LIBRARY_SUFFIXES ${save} )
107
+
108
+ # get version of the library from the dynamic library name
109
+ get_filename_component ( GRAPHBLAS_LIBRARY ${GRAPHBLAS_LIBRARY} REALPATH )
110
+ get_filename_component ( GRAPHBLAS_FILENAME ${GRAPHBLAS_LIBRARY} NAME )
111
+ string (
112
+ REGEX MATCH "[0-9]+.[0-9]+.[0-9]+"
113
+ GRAPHBLAS_VERSION
114
+ ${GRAPHBLAS_FILENAME}
80
115
)
81
- set (GRAPHBLAS_LIBRARIES ${GRAPHBLAS_LIBRARY} )
82
116
83
- include (FindPackageHandleStandardArgs)
117
+ # set ( GRAPHBLAS_VERSION "" )
118
+ if ( EXISTS "${GRAPHBLAS_INCLUDE_DIR} " AND NOT GRAPHBLAS_VERSION )
119
+ # if the version does not appear in the filename, read the include file
120
+ file ( STRINGS ${GRAPHBLAS_INCLUDE_DIR} /GraphBLAS.h GRAPHBLAS_MAJOR_STR
121
+ REGEX "define GxB_IMPLEMENTATION_MAJOR" )
122
+ file ( STRINGS ${GRAPHBLAS_INCLUDE_DIR} /GraphBLAS.h GRAPHBLAS_MINOR_STR
123
+ REGEX "define GxB_IMPLEMENTATION_MINOR" )
124
+ file ( STRINGS ${GRAPHBLAS_INCLUDE_DIR} /GraphBLAS.h GRAPHBLAS_PATCH_STR
125
+ REGEX "define GxB_IMPLEMENTATION_SUB" )
126
+ message ( STATUS "major: ${GRAPHBLAS_MAJOR_STR} " )
127
+ message ( STATUS "minor: ${GRAPHBLAS_MINOR_STR} " )
128
+ message ( STATUS "patch: ${GRAPHBLAS_PATCH_STR} " )
129
+ string ( REGEX MATCH "[0-9]+" GRAPHBLAS_MAJOR ${GRAPHBLAS_MAJOR_STR} )
130
+ string ( REGEX MATCH "[0-9]+" GRAPHBLAS_MINOR ${GRAPHBLAS_MINOR_STR} )
131
+ string ( REGEX MATCH "[0-9]+" GRAPHBLAS_PATCH ${GRAPHBLAS_PATCH_STR} )
132
+ set (GRAPHBLAS_VERSION "${GRAPHBLAS_MAJOR} .${GRAPHBLAS_MINOR} .${GRAPHBLAS_PATCH} " )
133
+ endif ( )
134
+
135
+ set ( GRAPHBLAS_LIBRARIES ${GRAPHBLAS_LIBRARY} )
136
+
137
+ include ( FindPackageHandleStandardArgs )
138
+
84
139
find_package_handle_standard_args(
85
140
GraphBLAS
86
141
REQUIRED_VARS GRAPHBLAS_LIBRARIES GRAPHBLAS_INCLUDE_DIR
@@ -90,14 +145,20 @@ find_package_handle_standard_args(
90
145
mark_as_advanced (
91
146
GRAPHBLAS_INCLUDE_DIR
92
147
GRAPHBLAS_LIBRARY
148
+ GRAPHBLAS_STATIC
93
149
GRAPHBLAS_LIBRARIES
94
150
)
95
151
96
152
if ( GRAPHBLAS_FOUND )
97
- message ( STATUS "GraphBLAS include dir: " ${GRAPHBLAS_INCLUDE_DIR} )
98
- message ( STATUS "GraphBLAS library: " ${GRAPHBLAS_LIBRARY} )
99
- message ( STATUS "GraphBLAS version: " ${GRAPHBLAS_VERSION} )
153
+ message ( STATUS "GraphBLAS version: ${GRAPHBLAS_VERSION} " )
154
+ message ( STATUS "GraphBLAS include: ${GRAPHBLAS_INCLUDE_DIR} " )
155
+ message ( STATUS "GraphBLAS library: ${GRAPHBLAS_LIBRARY} " )
156
+ message ( STATUS "GraphBLAS static: ${GRAPHBLAS_STATIC} " )
100
157
else ( )
101
158
message ( STATUS "GraphBLAS not found" )
159
+ set ( GRAPHBLAS_INCLUDE_DIR "" )
160
+ set ( GRAPHBLAS_LIBRARIES "" )
161
+ set ( GRAPHBLAS_LIBRARY "" )
162
+ set ( GRAPHBLAS_STATIC "" )
102
163
endif ( )
103
164
0 commit comments