diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index d5afaa4909..8e9037b5d8 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -496,6 +496,11 @@ int main(int argc, char **argv) { case 's': /* reverse output */ reverseout = 1; continue; + case '-': /* long option */ + if (strcmp(*argv, "--version") == 0) { + (void)printf("%s\n", pj_get_version()); + exit(0); + } default: emess(1, "invalid option: -%c", *arg); break; diff --git a/src/proj_internal.h b/src/proj_internal.h index 55abb8c115..f303a75f9a 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -1004,6 +1004,7 @@ int pj_has_inverse(PJ *); char *pj_strdup(const char *str); const char PROJ_DLL *pj_get_release(void); +const char PROJ_DLL *pj_get_version(void); void pj_acquire_lock(void); void pj_release_lock(void); diff --git a/src/release.cpp b/src/release.cpp index 5742f3b6a3..db28ecfbe9 100644 --- a/src/release.cpp +++ b/src/release.cpp @@ -6,6 +6,11 @@ #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) +char const pj_version[] = STR(PROJ_VERSION_MAJOR) "." STR( + PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH); + +const char *pj_get_version() { return pj_version; } + char const pj_release[] = "Rel. " STR(PROJ_VERSION_MAJOR) "." STR( PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH) ", " "September 1st, 2023";