Reuse macro to format version string

Change-Id: Ib21f2d8f06b6594dae410681d16a738b8b75c89a
diff --git a/include/ceres/version.h b/include/ceres/version.h
index 2d5d000..fe6c288 100644
--- a/include/ceres/version.h
+++ b/include/ceres/version.h
@@ -40,10 +40,16 @@
 #define CERES_TO_STRING_HELPER(x) #x
 #define CERES_TO_STRING(x) CERES_TO_STRING_HELPER(x)
 
+// clang-format off
+#define CERES_SEMVER_VERSION(MAJOR, MINOR, PATCH) \
+  CERES_TO_STRING(MAJOR) "."                      \
+  CERES_TO_STRING(MINOR) "."                      \
+  CERES_TO_STRING(PATCH)
+// clang-format on
+
 // The Ceres version as a string; for example "1.9.0".
-#define CERES_VERSION_STRING                                    \
-  CERES_TO_STRING(CERES_VERSION_MAJOR)                          \
-  "." CERES_TO_STRING(CERES_VERSION_MINOR) "." CERES_TO_STRING( \
-      CERES_VERSION_REVISION)
+#define CERES_VERSION_STRING \
+  CERES_SEMVER_VERSION(      \
+      CERES_VERSION_MAJOR, CERES_VERSION_MINOR, CERES_VERSION_REVISION)
 
 #endif  // CERES_PUBLIC_VERSION_H_
diff --git a/internal/ceres/solver_utils.cc b/internal/ceres/solver_utils.cc
index 3356f3b..f5fbf05 100644
--- a/internal/ceres/solver_utils.cc
+++ b/internal/ceres/solver_utils.cc
@@ -40,17 +40,12 @@
 
 namespace ceres::internal {
 
-// clang-format off
-#define CERES_EIGEN_VERSION                 \
-  CERES_TO_STRING(EIGEN_WORLD_VERSION) "."  \
-  CERES_TO_STRING(EIGEN_MAJOR_VERSION) "."  \
-  CERES_TO_STRING(EIGEN_MINOR_VERSION)
-// clang-format on
-
 constexpr char kVersion[] =
     // clang-format off
-  CERES_VERSION_STRING
-  "-eigen-(" CERES_EIGEN_VERSION ")"
+  CERES_VERSION_STRING "-eigen-("
+  CERES_SEMVER_VERSION(EIGEN_WORLD_VERSION,
+                       EIGEN_MAJOR_VERSION,
+                       EIGEN_MINOR_VERSION) ")"
 
 #ifdef CERES_NO_LAPACK
   "-no_lapack"