Skip to content

sergiud/SuiteSparse

CMake support for SuiteSparse

Linux macOS Windows

This repository provides two things:

  1. Copies of the official versions of SuiteSparse by T. A. Davis et al. Please use the master branch.
  2. Specifically, the cmake branch of the repository also implements native CMake support which allows to easily compile SuiteSparse (including CXSparse) on a variety of platforms.

The CMake support layer is provided under the Apache License 2.0. Modifications to the SuiteSparse code base are made available under the same conditions as the original code.

The original SuiteSparse README can be found here.

Highlights

Besides full CMake support, this branch provides the following additions:

  • CUDA support
  • DLL export on Windows and hidden symbols by default (-fvisibility=hidden) which enables link time optimization (LTO)
  • MinGW BLAS/LAPACK can be used to compile SuiteSparse using Visual Studio
  • CPack support

Requirements

  • C99 compiler (or Microsoft C compiler with complex math support)
  • CMake 3.22 or newer
  • SuiteSparse only (not required for CXSparse):
    • BLAS
    • LAPACK
    • (optional) C++98 compiler
    • (optional) CUDA compiler and toolkit
    • (optional) Fortran compiler
    • (optional) METIS
    • (optional) TBB prior to version 2021.4

Getting Started

First, compile using

$ cmake -S . -B build/
$ cmake --build build/

Then, one can consume SuiteSparse either directly from the build directory or after installing the project as follows:

find_package (SuiteSparse 5.12 NO_MODULE)

add_executable (myexe main.cpp)
target_link_libraries (myexe PRIVATE SuiteSparse::CHOLMOD)

Background

The repository was created in 2015 to keep track of original releases before SuiteSparse became a Github project at the end of 2019. At the same time, the cmake branch introduced modifications to the original code base in order to enable native CMake support across major platforms.

While suitesparse-metis-for-windows was already available at the time and confusingly worked not only on Windows as the name might suggest, its CMake support did have several limitations. In particular, the implementation did not provide relocatable CMake package configuration and awkwardly relied on Python for preprocessing source files (as of August 2021, it still does.)

For IP (and legal) reasons, the provided CMake additions cannot become part of official SuiteSparse releases. For more information, please refer to this post.