Add SuiteSparse::IsConstrainedApproximateMinimumDegreeOrderingAvailable. This allows checking for the availability of CAMD without depending on a preprocessor symbol, which can be the source of subtle bugs if the file defining that symbol was not included. Change-Id: I6f1ef91a20baeecf68e8dd467ebe707dde8c5f79
diff --git a/internal/ceres/suitesparse.h b/internal/ceres/suitesparse.h index 0a7ea97..f27e338 100644 --- a/internal/ceres/suitesparse.h +++ b/internal/ceres/suitesparse.h
@@ -283,9 +283,21 @@ #else // CERES_NO_SUITESPARSE -class SuiteSparse {}; typedef void cholmod_factor; +class SuiteSparse { + // Defining this static function even when SuiteSparse is not + // available, allows client code to check for the presence of CAMD + // without checking for the absence of the CERES_NO_CAMD symbol. + // + // This is safer because the symbol maybe missing due to a user + // accidently not including suitesparse.h in their code when + // checking for the symbol. + static bool IsConstrainedApproximateMinimumDegreeOrderingAvailable() { + return false; + } +}; + #endif // CERES_NO_SUITESPARSE #endif // CERES_INTERNAL_SUITESPARSE_H_