Skip to content

Commit 2357545

Browse files
committed
cmake: enable C++ on demand
1 parent 3b9927e commit 2357545

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.github/workflows/windows.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ jobs:
7070
restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}-ccache-
7171

7272
- name: Configure
73-
env:
74-
CC: ${{matrix.env}}-w64-mingw32-gcc
75-
CXX: ${{matrix.env}}-w64-mingw32-g++
7673
run: |
7774
cmake -S . -B build_${{matrix.build_type}}/ \
7875
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \

CMakeLists.txt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
2222
set (CMAKE_CUDA_ARCHITECTURES 75)
2323
endif (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
2424

25-
project (SuiteSparse LANGUAGES C CXX VERSION 5.12.0
25+
project (SuiteSparse
2626
DESCRIPTION "A suite of sparse matrix packages"
2727
HOMEPAGE_URL http://faculty.cse.tamu.edu/davis/suitesparse.html
28+
LANGUAGES C
29+
VERSION 5.12.0
2830
)
2931

3032
set (CMAKE_DEBUG_POSTFIX _debug)
@@ -57,9 +59,7 @@ include (InstallRequiredSystemLibraries)
5759
include (SuiteSparseBase)
5860

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

71+
check_language (CUDA)
72+
check_language (CXX)
73+
check_language (Fortran)
74+
7175
cmake_dependent_option (BUILD_SHARED_LIBS "Build shared libraires" OFF "WITH_LICENSE STREQUAL \"GPL\"" ON)
7276

77+
cmake_dependent_option (WITH_CUDA "Enable CUDA support" ON "CMAKE_CXX_COMPILER AND CMAKE_CUDA_COMPILER" OFF)
78+
cmake_dependent_option (WITH_FORTRAN "Enables Fortran support" ON "CMAKE_Fortran_COMPILER" OFF)
79+
7380
cmake_dependent_option (WITH_LGPL "Enable GNU LGPL modules" ON "WITH_LICENSE MATCHES \"GPL\"" OFF)
7481
cmake_dependent_option (WITH_GPL "Enable GNU GPL modules" ON "WITH_LICENSE STREQUAL \"GPL\"" OFF)
7582

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

8592
if (WITH_CUDA)
86-
check_language (CUDA)
87-
88-
if (CMAKE_CUDA_COMPILER)
89-
enable_language (CUDA)
90-
endif (CMAKE_CUDA_COMPILER)
93+
enable_language (CUDA)
9194
else (WITH_CUDA)
9295
set (CMAKE_FIND_PACKAGE_DISABLE_CUDAToolkit ON)
9396
endif (WITH_CUDA)
9497

95-
if (WITH_FORTRAN)
96-
check_language (Fortran)
98+
# CUDA and SPQR require a C++ compiler
99+
if (WITH_SUPERNODAL OR WITH_CUDA)
100+
enable_language (CXX)
101+
endif (WITH_SUPERNODAL OR WITH_CUDA)
97102

98-
if (CMAKE_Fortran_COMPILER)
99-
enable_language (Fortran)
100-
endif (CMAKE_Fortran_COMPILER)
103+
if (WITH_FORTRAN)
104+
enable_language (Fortran)
101105
endif (WITH_FORTRAN)
102106

103107
check_c_compiler_flag (-Qstd=c99 HAVE_QSTD_C99)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ Besides full CMake support, this branch provides the following additions:
3434

3535
## Requirements
3636

37-
* C and C++ compilers
37+
* C99 compiler (or Microsoft C compiler with complex math support)
3838
* CMake 3.22 or newer
3939
* SuiteSparse only (not required for CXSparse):
4040
- BLAS
4141
- LAPACK
42+
- (optional) C++98 compiler
4243
- (optional) CUDA compiler and toolkit
4344
- (optional) Fortran compiler
4445
- (optional) METIS

0 commit comments

Comments
 (0)