diff --git a/libs/util/source/executable_path.cpp b/libs/util/source/executable_path.cpp index ba8a9dc8..3095fe52 100644 --- a/libs/util/source/executable_path.cpp +++ b/libs/util/source/executable_path.cpp @@ -8,6 +8,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + namespace psemek::util { @@ -29,6 +33,12 @@ namespace psemek::util return std::filesystem::path(result); #elif defined __linux__ return std::filesystem::canonical("/proc/self/exe"); +#elif defined __APPLE__ + uint32_t path_length = 0; + _NSGetExecutablePath(nullptr, &path_length); + std::string path(path_length, '\0'); + _NSGetExecutablePath(path.data(), &path_length); + return std::filesystem::path(std::move(path)); #else throw exception("executable_path() is not implemented for this platform"); #endif