Skip to content

Commit 1041a57

Browse files
SUITESPARSE_USE_STRICT
1 parent 54e4c96 commit 1041a57

File tree

3 files changed

+65
-20
lines changed

3 files changed

+65
-20
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ endif ( )
158158
option ( SUITESPARSE_USE_OPENMP "ON (default): Use OpenMP if available. OFF: Do not use OpenMP" ON )
159159
option ( LAGRAPH_USE_OPENMP "ON: Use OpenMP in LAGraph if available. OFF: Do not use OpenMP. (Default: SUITESPARSE_USE_OPENMP)" ${SUITESPARSE_USE_OPENMP} )
160160
if ( COVERAGE )
161+
set ( LAGRAPH_USE_OPENMP OFF ) # OK: test coverage is enabled
161162
message ( STATUS "OpenMP disabled for test coverage" )
162163
else ( )
163164
if ( LAGRAPH_USE_OPENMP )
@@ -171,6 +172,17 @@ else ( )
171172
endif ( )
172173
endif ( )
173174

175+
if ( OpenMP_C_FOUND )
176+
set ( LAGRAPH_HAS_OPENMP ON )
177+
else ( )
178+
set ( LAGRAPH_HAS_OPENMP OFF )
179+
endif ( )
180+
181+
# check for strict usage
182+
if ( SUITESPARSE_USE_STRICT AND LAGRAPH_USE_OPENMP AND NOT LAGRAPH_HAS_OPENMP )
183+
message ( FATAL_ERROR "OpenMP required for LAGraph but not found" )
184+
endif ( )
185+
174186
#-------------------------------------------------------------------------------
175187
# report status
176188
#-------------------------------------------------------------------------------

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ library:
5555

5656
# install only in SuiteSparse/lib and SuiteSparse/include
5757
local:
58-
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DLOCAL_INSTALL=1 .. && cmake --build . --config Release -j${JOBS} )
58+
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DSUITESPARSE_LOCAL_INSTALL=1 .. && cmake --build . --config Release -j${JOBS} )
5959

6060
# install CMAKE_INSTALL_PREFIX
6161
global:
62-
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DLOCAL_INSTALL=0 .. && cmake --build . --config Release -j${JOBS} )
62+
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DSUITESPARSE_LOCAL_INSTALL=0 .. && cmake --build . --config Release -j${JOBS} )
6363

6464
vanilla:
6565
( cd build && cmake $(CMAKE_OPTIONS) -USUITESPARSE_PKGFILEDIR -DLAGRAPH_VANILLA=1 .. && cmake --build . --config Release -j${JOBS} )

cmake_modules/SuiteSparsePolicy.cmake

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@
1515
# set ( CMAKE_BUILD_TYPE Debug )
1616
#
1717
# SUITESPARSE_USE_CUDA: if OFF, CUDA is disabled. if ON, CUDA is enabled,
18-
# if available.
18+
# if available. Ignored for MSVC.
1919
# Default: ON.
2020
#
21-
# LOCAL_INSTALL: if true, "cmake --install" will install
21+
# SUITESPARSE_LOCAL_INSTALL: if true, "cmake --install" will install
2222
# into SuiteSparse/lib and SuiteSparse/include.
2323
# if false, "cmake --install" will install into the
2424
# default prefix (or the one configured with
2525
# CMAKE_INSTALL_PREFIX). Requires cmake 3.19.
2626
# This is ignored when using the root CMakeLists.txt.
2727
# Set CMAKE_INSTALL_PREFIX instead.
28-
# Default: false
28+
# Default: OFF
2929
#
3030
# BUILD_SHARED_LIBS: if true, shared libraries are built.
31-
# Default: true.
31+
# Default: ON.
3232
#
3333
# BUILD_STATIC_LIBS: if true, static libraries are built.
34-
# Default: true, except for GraphBLAS, which
34+
# Default: ON, except for GraphBLAS, which
3535
# takes a long time to compile so the default for
3636
# GraphBLAS is false.
3737
#
@@ -49,10 +49,10 @@
4949
# Both settings must appear, or neither.
5050
# Default: neither are defined.
5151
#
52-
# BLA_STATIC: if true, use static linkage for BLAS and LAPACK.
53-
# Default: false
52+
# BLA_STATIC: if ON, use static linkage for BLAS and LAPACK.
53+
# Default: not set (that is, the same as OFF)
5454
#
55-
# SUITESPARSE_ALLOW_64BIT_BLAS if true, SuiteSparse will search for both
55+
# SUITESPARSE_USE_64BIT_BLAS if true, SuiteSparse will search for both
5656
# 32-bit and 64-bit BLAS. If false, only 32-bit BLAS
5757
# will be searched for. Ignored if BLA_VENDOR and
5858
# BLA_SIZEOF_INTEGER are defined.
@@ -81,12 +81,25 @@
8181
# installed in the subfolder `pkgconfig` of the directory
8282
# where the (static) libraries will be installed.
8383
# Default: CMAKE_INSTALL_PREFIX, or SuiteSparse/lib if
84-
# LOCAL_INSTALL is enabled.
84+
# SUITESPARSE_LOCAL_INSTALL is enabled.
8585
#
8686
# SUITESPARSE_INCLUDEDIR_POSTFIX : Postfix for installation target of
8787
# header from SuiteSparse. Default: suitesparse, so the
8888
# default include directory is:
8989
# CMAKE_INSTALL_PREFIX/include/suitesparse
90+
#
91+
# SUITESPARSE_USE_STRICT: SuiteSparse has many user-definable settings of the
92+
# form SUITESPARSE_USE_* or (package)_USE_* for some
93+
# particular package. In general, these settings are not
94+
# strict. For example, if SUITESPARSE_USE_OPENMP is
95+
# ON then OpenMP is preferred, but SuiteSparse can be
96+
# used without OpenMP so no error is generated if OpenMP
97+
# is not found. However, if SUITESPARSE_USE_STRICT is
98+
# ON then all *_USE_* settings are treated strictly
99+
# and an error occurs if any are set to ON but the
100+
# corresponding package or setting is not available. The
101+
# *_USE_SYSTEM_* settings are always treated as strict.
102+
# Default: OFF.
90103

91104
message ( STATUS "Source: ${CMAKE_SOURCE_DIR} ")
92105
message ( STATUS "Build: ${CMAKE_BINARY_DIR} ")
@@ -108,6 +121,9 @@ include ( GNUInstallDirs )
108121
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
109122
${CMAKE_SOURCE_DIR}/cmake_modules )
110123

124+
# strict usage
125+
option ( SUITESPARSE_USE_STRICT "ON: treat all _USE__ settings as strict if they are ON. OFF (default): consider *_USE_* as preferences, not strict" OFF )
126+
111127
# build the demos
112128
option ( SUITESPARSE_DEMOS "ON: Build the demo programs. OFF (default): do not build the demo programs." OFF )
113129

@@ -131,10 +147,10 @@ endif ( )
131147

132148
# installation options
133149
if ( NOT SUITESPARSE_ROOT_CMAKELISTS AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0" )
134-
# the LOCAL_INSTALL option requires cmake 3.19.0 or later
135-
option ( LOCAL_INSTALL "Install in SuiteSparse/lib" OFF )
150+
# the SUITESPARSE_LOCAL_INSTALL option requires cmake 3.19.0 or later
151+
option ( SUITESPARSE_LOCAL_INSTALL "Install in SuiteSparse/lib" OFF )
136152
else ( )
137-
set ( LOCAL_INSTALL OFF )
153+
set ( SUITESPARSE_LOCAL_INSTALL OFF )
138154
endif ( )
139155

140156
if ( SUITESPARSE_SECOND_LEVEL )
@@ -150,10 +166,10 @@ endif ( )
150166
set ( INSIDE_SUITESPARSE OFF )
151167
if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
152168
# determine if this Package is inside the SuiteSparse folder
153-
if ( LOCAL_INSTALL )
169+
if ( SUITESPARSE_LOCAL_INSTALL )
154170
# if you do not want to install local copies of SuiteSparse
155171
# packages in SuiteSparse/lib and SuiteSparse/, set
156-
# LOCAL_INSTALL to false in your CMake options.
172+
# SUITESPARSE_LOCAL_INSTALL to false in your CMake options.
157173
if ( SUITESPARSE_SECOND_LEVEL )
158174
# the package is normally located at the 2nd level inside SuiteSparse
159175
# (SuiteSparse/GraphBLAS/GraphBLAS/ for example)
@@ -169,7 +185,7 @@ if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
169185
endif ( )
170186

171187
if ( NOT INSIDE_SUITESPARSE )
172-
message ( FATAL_ERROR "Unsupported layout for local installation. Correct the directory layout or unset LOCAL_INSTALL." )
188+
message ( FATAL_ERROR "Unsupported layout for local installation. Correct the directory layout or unset SUITESPARSE_LOCAL_INSTALL." )
173189
endif ( )
174190

175191
endif ( )
@@ -178,7 +194,7 @@ endif ( )
178194
set ( SUITESPARSE_INCLUDEDIR_POSTFIX "suitesparse" CACHE STRING
179195
"Postfix for installation target of header from SuiteSparse (default: \"suitesparse\")" )
180196

181-
if ( LOCAL_INSTALL )
197+
if ( SUITESPARSE_LOCAL_INSTALL )
182198
if ( INSIDE_SUITESPARSE )
183199
# ../lib and ../include exist: the package is inside SuiteSparse.
184200
# find ( REAL_PATH ...) requires cmake 3.19.
@@ -242,6 +258,12 @@ if ( SUITESPARSE_USE_FORTRAN )
242258
endif ( )
243259
else ( )
244260
message ( STATUS "Fortran: not enabled" )
261+
set ( SUITESPARSE_HAS_FORTRAN OFF )
262+
endif ( )
263+
264+
# check for strict usage
265+
if ( SUITESPARSE_USE_STRICT AND SUITESPARSE_USE_FORTRAN AND NOT SUITESPARSE_HAS_FORTRAN )
266+
message ( FATAL_ERROR "Fortran required for SuiteSparse but not found" )
245267
endif ( )
246268

247269
# default C-to-Fortran name mangling if Fortran compiler not found
@@ -259,8 +281,14 @@ endif ( )
259281
# find CUDA
260282
#-------------------------------------------------------------------------------
261283

262-
option ( SUITESPARSE_USE_CUDA "Enable CUDA acceleration for SuiteSparse" ON )
263-
if ( SUITESPARSE_USE_CUDA AND NOT MSVC )
284+
if ( MSVC )
285+
# do not attempt to use CUDA on MSVC
286+
set ( SUITESPARSE_USE_CUDA OFF )
287+
else ( )
288+
option ( SUITESPARSE_USE_CUDA "ON (default): enable CUDA acceleration for SuiteSparse, OFF: do not use CUDA" ON )
289+
endif ( )
290+
291+
if ( SUITESPARSE_USE_CUDA )
264292

265293
# try finding CUDA
266294
check_language ( CUDA )
@@ -304,3 +332,8 @@ else ( )
304332
message ( STATUS "CUDA: not enabled" )
305333
endif ( )
306334

335+
# check for strict usage
336+
if ( SUITESPARSE_USE_STRICT AND SUITESPARSE_USE_CUDA AND NOT SUITESPARSE_HAS_CUDA )
337+
message ( FATAL_ERROR "CUDA required for SuiteSparse but not found" )
338+
endif ( )
339+

0 commit comments

Comments
 (0)