From bae04fa89954ae0f4594e9fe8d38073b3e0ae51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Tue, 10 Jan 2023 11:48:17 +0100 Subject: [PATCH] ModelTree::findGccOnMacOS() now returns a std::filesystem::path --- src/ModelTree.cc | 16 ++++++++-------- src/ModelTree.hh | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ModelTree.cc b/src/ModelTree.cc index ba82c44d..35aeeccf 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 7f41020f..cd936ca0 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 -- GitLab