diff --git a/modules/fftw/src/cpp/FFTWWrapper.cpp b/modules/fftw/src/cpp/FFTWWrapper.cpp index cf8584d1f8..9c5ab55b3c 100644 --- a/modules/fftw/src/cpp/FFTWWrapper.cpp +++ b/modules/fftw/src/cpp/FFTWWrapper.cpp @@ -11,6 +11,7 @@ #if WITH_OPENMP #include #endif +#include #include "FFTWDynamicLibrary.hpp" #include "FFTWWrapper.hpp" #include "DynamicLibrary.hpp" @@ -192,6 +193,34 @@ freeFFTWLibrary() return false; } //============================================================================= +#if defined(__APPLE__) +static bool +loadFFTWLibraryOnMacOs() +{ + bool res = false; + char const* CONDA_PREFIX_char = std::getenv("CONDA_PREFIX"); + if (CONDA_PREFIX_char) { + std::string CONDA_LIB = std::string(CONDA_PREFIX_char) + "/lib/"; + std::string fftwLibraryName = CONDA_LIB + "libfftw3.3" + get_dynamic_library_extension(); + std::string fftwfLibraryName = CONDA_LIB + "libfftw3f" + get_dynamic_library_extension(); + res = loadFFTWLibrary(utf8_to_wstring(fftwLibraryName), utf8_to_wstring(fftwfLibraryName)); + } + if (!res) { + char const* HOMEBREW_PREFIX_char = std::getenv("HOMEBREW_PREFIX"); + if (HOMEBREW_PREFIX_char) { + std::string HOMEBREW_LIB = std::string(HOMEBREW_PREFIX_char) + "/lib/"; + std::string fftwLibraryName + = HOMEBREW_LIB + "libfftw3.3" + get_dynamic_library_extension(); + std::string fftwfLibraryName + = HOMEBREW_LIB + "libfftw3f" + get_dynamic_library_extension(); + res = loadFFTWLibrary( + utf8_to_wstring(fftwLibraryName), utf8_to_wstring(fftwfLibraryName)); + } + } + return res; +} +#endif +//============================================================================= bool loadFFTWLibrary() { @@ -213,12 +242,15 @@ loadFFTWLibrary() res = loadFFTWLibrary(utf8_to_wstring(fftwLibraryName), utf8_to_wstring(fftwfLibraryName)); } if (!res) { - // try with version 3.3 macos specific std::string fftwLibraryName = "libfftw3.3" + get_dynamic_library_extension(); - std::string fftwfLibraryName = "libfftw3f" + get_dynamic_library_extension() + ".3"; + std::string fftwfLibraryName = "libfftw3f" + get_dynamic_library_extension(); res = loadFFTWLibrary(utf8_to_wstring(fftwLibraryName), utf8_to_wstring(fftwfLibraryName)); } - +#if defined(__APPLE__) + if (!res) { + res = loadFFTWLibraryOnMacOs(); + } +#endif #endif if (res) { #if WITH_OPENMP