Skip to content

Commit

Permalink
cmake: enable C++ on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Jun 5, 2022
1 parent 3b9927e commit 2357545
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ jobs:
restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}-ccache-

- name: Configure
env:
CC: ${{matrix.env}}-w64-mingw32-gcc
CXX: ${{matrix.env}}-w64-mingw32-g++
run: |
cmake -S . -B build_${{matrix.build_type}}/ \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
Expand Down
32 changes: 18 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set (CMAKE_CUDA_ARCHITECTURES 75)
endif (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)

project (SuiteSparse LANGUAGES C CXX VERSION 5.12.0
project (SuiteSparse
DESCRIPTION "A suite of sparse matrix packages"
HOMEPAGE_URL http://faculty.cse.tamu.edu/davis/suitesparse.html
LANGUAGES C
VERSION 5.12.0
)

set (CMAKE_DEBUG_POSTFIX _debug)
Expand Down Expand Up @@ -57,9 +59,7 @@ include (InstallRequiredSystemLibraries)
include (SuiteSparseBase)

option (BUILD_CXSPARSE "Build CXSparse" ON)
option (WITH_CUDA "Enable CUDA support" ON)
option (WITH_DEMOS "Build demos" ON)
option (WITH_FORTRAN "Enables Fortran support" ON)
option (WITH_METIS "Enables METIS support" ON)
option (WITH_OPENMP "Enable OpenMP support" ON)
option (WITH_PRINT "Print diagnostic messages" OFF)
Expand All @@ -68,8 +68,15 @@ option (WITH_TBB "Enables Intel Threading Building Blocks support" ON)
set (WITH_LICENSE "GPL" CACHE STRING "Software license the binary distribution should adhere")
set_property (CACHE WITH_LICENSE PROPERTY STRINGS "Minimal;GPL;LGPL")

check_language (CUDA)
check_language (CXX)
check_language (Fortran)

cmake_dependent_option (BUILD_SHARED_LIBS "Build shared libraires" OFF "WITH_LICENSE STREQUAL \"GPL\"" ON)

cmake_dependent_option (WITH_CUDA "Enable CUDA support" ON "CMAKE_CXX_COMPILER AND CMAKE_CUDA_COMPILER" OFF)
cmake_dependent_option (WITH_FORTRAN "Enables Fortran support" ON "CMAKE_Fortran_COMPILER" OFF)

cmake_dependent_option (WITH_LGPL "Enable GNU LGPL modules" ON "WITH_LICENSE MATCHES \"GPL\"" OFF)
cmake_dependent_option (WITH_GPL "Enable GNU GPL modules" ON "WITH_LICENSE STREQUAL \"GPL\"" OFF)

Expand All @@ -80,24 +87,21 @@ cmake_dependent_option (WITH_CAMD "Enable interfaces to CAMD, CCOLAMD, CSYMAMD i
cmake_dependent_option (WITH_CHECK "Enable the Check module" ON "WITH_LGPL" OFF)
cmake_dependent_option (WITH_MATRIXOPS "Enable the MatrixOps module" ON "WITH_GPL AND WITH_CHOLMOD" OFF)
cmake_dependent_option (WITH_MODIFY "Enable the Modify module" ON "WITH_GPL AND WITH_CHOLMOD" OFF)
cmake_dependent_option (WITH_SUPERNODAL "Enable the Supernodal module" ON "WITH_GPL" OFF)
cmake_dependent_option (WITH_SUPERNODAL "Enable the Supernodal module" ON "CMAKE_CXX_COMPILER AND WITH_GPL" OFF)

if (WITH_CUDA)
check_language (CUDA)

if (CMAKE_CUDA_COMPILER)
enable_language (CUDA)
endif (CMAKE_CUDA_COMPILER)
enable_language (CUDA)
else (WITH_CUDA)
set (CMAKE_FIND_PACKAGE_DISABLE_CUDAToolkit ON)
endif (WITH_CUDA)

if (WITH_FORTRAN)
check_language (Fortran)
# CUDA and SPQR require a C++ compiler
if (WITH_SUPERNODAL OR WITH_CUDA)
enable_language (CXX)
endif (WITH_SUPERNODAL OR WITH_CUDA)

if (CMAKE_Fortran_COMPILER)
enable_language (Fortran)
endif (CMAKE_Fortran_COMPILER)
if (WITH_FORTRAN)
enable_language (Fortran)
endif (WITH_FORTRAN)

check_c_compiler_flag (-Qstd=c99 HAVE_QSTD_C99)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ Besides full CMake support, this branch provides the following additions:

## Requirements

* C and C++ compilers
* 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
Expand Down

0 comments on commit 2357545

Please sign in to comment.