diff --git a/src/ModelTree.cc b/src/ModelTree.cc index ba82c44df86a3d6a33f2f89b8d9f21b1184a4ff6..35aeeccf925e639f5e85816d0b2b9d281323e8fb 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -1634,14 +1634,14 @@ ModelTree::matlab_arch(const string &mexext) } #ifdef __APPLE__ -string +filesystem::path ModelTree::findGccOnMacos(const string &mexext) { const string macos_gcc_version {"12"}; // doc/manual/source/installation-and-configuration.rst // should be updated when this is changed char dynare_preprocessor_path[PATH_MAX]; uint32_t size = PATH_MAX; - string local_gcc_path; + filesystem::path local_gcc_path; if (_NSGetExecutablePath(dynare_preprocessor_path, &size) == 0) { string s = dynare_preprocessor_path; @@ -1650,13 +1650,13 @@ ModelTree::findGccOnMacos(const string &mexext) // if user did not choose to install gcc locally via the pkg-installer then we need to find GNU gcc // homebrew binaries are located in /usr/local/bin/ on x86_64 systems and in /opt/homebrew/bin/ on arm64 systems - if (filesystem::exists(local_gcc_path)) + if (exists(local_gcc_path)) return local_gcc_path; - else if (string global_gcc_path = "/usr/local/bin/gcc-" + macos_gcc_version; - filesystem::exists(global_gcc_path) && mexext == "mexmaci64") + else if (filesystem::path global_gcc_path {"/usr/local/bin/gcc-" + macos_gcc_version}; + exists(global_gcc_path) && mexext == "mexmaci64") return global_gcc_path; - else if (string global_gcc_path = "/opt/homebrew/bin/gcc-" + macos_gcc_version; - filesystem::exists(global_gcc_path) && mexext == "mexmaca64") + else if (filesystem::path global_gcc_path {"/opt/homebrew/bin/gcc-" + macos_gcc_version}; + exists(global_gcc_path) && mexext == "mexmaca64") return global_gcc_path; else { @@ -1693,7 +1693,7 @@ ModelTree::compileMEX(const filesystem::path &output_dir, const string &output_b #ifdef __APPLE__ /* On macOS, enforce GCC, otherwise Clang will be used, and it does not accept our custom optimization flags (see dynare#1797) */ - string gcc_path = findGccOnMacos(mexext); + filesystem::path gcc_path {findGccOnMacos(mexext)}; if (setenv("CC", gcc_path.c_str(), 1) != 0) { cerr << "Can't set CC environment variable" << endl; diff --git a/src/ModelTree.hh b/src/ModelTree.hh index 7f41020f5715cd7479a7b0c945a53dad941e7569..cd936ca069d5416739a0e018e7747a94ada52ad2 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -598,7 +598,7 @@ private: static string matlab_arch(const string &mexext); #ifdef __APPLE__ //! Finds a suitable GCC compiler on macOS - static string findGccOnMacos(const string &mexext); + static filesystem::path findGccOnMacos(const string &mexext); #endif /* Compiles a MEX file (if link=true) or an object file to be linked later into a MEX file (if link=false). The compilation is done in separate