Skip to content

Commit 7a07256

Browse files
authored
Merge pull request #1235 from NexiusTailer/master
Some more fixes for macOS
2 parents 392a633 + 2fcd410 commit 7a07256

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ cmake --build . --config RelWithDebInfo
5858

5959
## Building on Mac
6060

61-
If you install conan via brew you must ensure you get the correct version; however, the cmake-conan script will not detect it from the default install location. You must therefore also alias it elsewhere:
61+
If you install conan via brew the cmake-conan script will not detect it from the default install location. You must therefore also alias it elsewhere:
6262

6363
```bash
64-
brew install conan@1
65-
sudo ln -s /usr/local/opt/conan@1/bin/conan /usr/local/bin/conan
64+
brew install conan
65+
sudo ln -s /usr/local/opt/conan/bin/conan /usr/local/bin/conan
6666
cd open.mp
6767
mkdir build
6868
cd build

Server/Source/util.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ static LARGE_INTEGER yo;
3131
#include <stdlib.h>
3232
#include <sys/time.h>
3333
#include <unistd.h>
34+
#ifdef __APPLE__
35+
#include <mach-o/dyld.h>
36+
#endif
3437
#define SET_TICKER_RESOLUTION(ms)
3538
#define LIBRARY_OPEN(path) dlopen(path, RTLD_LAZY | RTLD_LOCAL)
3639
#define LIBRARY_OPEN_GLOBAL(path) dlopen(path, RTLD_LAZY | RTLD_GLOBAL)
@@ -153,6 +156,19 @@ ghc::filesystem::path GetExecutablePath()
153156
{
154157
return ghc::filesystem::path();
155158
}
159+
#elif defined(__APPLE__)
160+
char path[4096] = { 0 };
161+
uint32_t size = sizeof(path);
162+
if (_NSGetExecutablePath(path, &size) == 0)
163+
{
164+
std::error_code ec;
165+
auto canonicalPath = ghc::filesystem::canonical(path, ec);
166+
return ec ? ghc::filesystem::path(path) : canonicalPath;
167+
}
168+
else
169+
{
170+
return ghc::filesystem::path();
171+
}
156172
#else
157173
return ghc::filesystem::canonical("/proc/self/exe");
158174
#endif

0 commit comments

Comments
 (0)