Skip to content

Commit

Permalink
Change version retrieving logic for mrtrix3 executables
Browse files Browse the repository at this point in the history
The strategy now matches what we do to get the library version.
  • Loading branch information
daljit46 committed Oct 1, 2024
1 parent 2c68665 commit 36f1ccc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
5 changes: 2 additions & 3 deletions cpp/lib/core/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ const std::thread::id main_thread_ID = std::this_thread::get_id();

const char *project_version = nullptr;
const char *project_build_date = nullptr;
const char *executable_uses_mrtrix_version = nullptr;

std::vector<std::string> raw_arguments_list;

Expand Down Expand Up @@ -1153,9 +1152,9 @@ void init(int cmdline_argc, const char *const *cmdline_argv) {
NAME.erase(NAME.size() - 4);
#endif

if (mrtrix_version != executable_uses_mrtrix_version) {
if (mrtrix_version != mrtrix_executable_version) {
Exception E("executable was compiled for a different version of the MRtrix3 library!");
E.push_back(std::string(" ") + NAME + " version: " + executable_uses_mrtrix_version);
E.push_back(std::string(" ") + NAME + " version: " + mrtrix_executable_version);
E.push_back(std::string(" library version: ") + mrtrix_version);
E.push_back("You may need to erase files left over from prior MRtrix3 versions;");
E.push_back("eg. core/version.cpp; src/exec_version.cpp");
Expand Down
2 changes: 0 additions & 2 deletions cpp/lib/core/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void set_project_version();
#ifdef MRTRIX_AS_R_LIBRARY

extern "C" void R_main(int *cmdline_argc, char **cmdline_argv) {
::MR::App::set_executable_uses_mrtrix_version();
#ifdef MRTRIX_PROJECT
::MR::App::set_project_version();
#endif
Expand Down Expand Up @@ -79,7 +78,6 @@ int main(int cmdline_argc, char **cmdline_argv) {
mxcsr |= (1 << 6); // denormals-are-zero
_mm_setcsr(mxcsr);
#endif
::MR::App::set_executable_uses_mrtrix_version();
#ifdef MRTRIX_PROJECT
::MR::App::set_project_version();
#endif
Expand Down
7 changes: 2 additions & 5 deletions cpp/lib/executable_version.cpp.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "executable_version.h"

namespace MR {
namespace App {
extern const char* executable_uses_mrtrix_version;
void set_executable_uses_mrtrix_version () { executable_uses_mrtrix_version = "@MRTRIX_VERSION@"; }
}
namespace MR::App {
const std::string mrtrix_executable_version = "@MRTRIX_VERSION@";
}
5 changes: 3 additions & 2 deletions cpp/lib/executable_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

#pragma once
#include <string>

namespace MR::App {
void set_executable_uses_mrtrix_version();
}
extern const std::string mrtrix_executable_version;
} // namespace MR::App

0 comments on commit 36f1ccc

Please sign in to comment.