diff --git a/ApplicationExeCode/RiaMain.cpp b/ApplicationExeCode/RiaMain.cpp index 700114d1cc..b8d35b48c2 100644 --- a/ApplicationExeCode/RiaMain.cpp +++ b/ApplicationExeCode/RiaMain.cpp @@ -48,7 +48,7 @@ RiaApplication* createApplication( int& argc, char* argv[] ) { for ( int i = 1; i < argc; ++i ) { - if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) || !qstrcmp( argv[i], "--version" ) ) + if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) ) { #ifdef ENABLE_GRPC return new RiaGrpcConsoleApplication( argc, argv ); diff --git a/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake b/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake index 5cdacb8332..8e2910f76a 100644 --- a/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake +++ b/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake @@ -34,3 +34,5 @@ #define RESINSIGHT_OCTAVE_VERSION "@OCTAVE_VERSION_STRING@" #define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@" + +#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@" \ No newline at end of file diff --git a/ApplicationLibCode/Application/RiaConsoleApplication.cpp b/ApplicationLibCode/Application/RiaConsoleApplication.cpp index 1e3c85c51e..97a4b8b88b 100644 --- a/ApplicationLibCode/Application/RiaConsoleApplication.cpp +++ b/ApplicationLibCode/Application/RiaConsoleApplication.cpp @@ -131,6 +131,7 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n if ( progOpt->option( "version" ) ) { QString text = QString( STRPRODUCTVER ) + "\n"; + text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n"; showFormattedTextInMessageBoxOrConsole( text ); diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 1a51c974df..461e99ec54 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -463,6 +463,16 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n return RiaApplication::ApplicationStatus::EXIT_COMPLETED; } + if ( progOpt->option( "version" ) ) + { + QString text = QString( STRPRODUCTVER ) + "\n"; + text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n"; + + showFormattedTextInMessageBoxOrConsole( text ); + + return RiaApplication::ApplicationStatus::EXIT_COMPLETED; + } + // Code generation // ----------------- if ( cvf::Option o = progOpt->option( "generate" ) ) diff --git a/CMakeLists.txt b/CMakeLists.txt index a74efe8d97..be662dc9da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,6 +324,12 @@ set(CMAKE_CXX_COMPILER_LAUNCHER ${TEMP_CMAKE_CXX_COMPILER_LAUNCHER}) # ############################################################################## find_package(Git QUIET) if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + execute_process( + COMMAND git log -1 --pretty=format:%h + OUTPUT_VARIABLE RESINSIGHT_GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET + ) + # Update submodules as needed option(RESINSIGHT_UPDATE_SUBMODULES "Check submodules during build" ON) mark_as_advanced(RESINSIGHT_UPDATE_SUBMODULES)