New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add macOS support #74
Comments
You saw what I said on the OpenMW IRC, didn't you? 😉 The best way to get the ball rolling is to have a Mac user try and build the project with CMake, and then leave their findings here. There aren't very many dependencies -- just SDL2, OpenAL Soft, WildMIDI, and a C++11 compiler. WildMIDI is even optional for now if you don't want music (with the There might need to be some changes to the top-level In order to have consistent macOS releases, we'd need someone on that operating system to maintain them, since I'm on Windows and @Ragora is on Linux. |
Yup, I did see you saying that nobody had asked for a Mac release, so I figured I'd do that. I'm a complete newbie to C++ (I have plenty of Java and Python experience though) and am especially confused with dependency management (on Java, we just use Gradle or Maven to download and build everything with one command, and in a sandboxed mode too). That said, I decided to give it a try. First, I installed CMake, OpenAL Soft, and SDL via Homebrew (WildMIDI wasn't available). I simply ran
Does this give you a clue as to what might be going wrong? |
Hmm, are you compiling in 32-bit mode by chance? We've gotten some warnings about other conversions between |
I don't think I'm compiling in 32-bit mode. Macs have been 64-bit for at least a decade (and Apple just announced that the next version of macOS will be the last to support 32-bit apps). I also tried adding properties to target macOS 10.12 (10.5 was the last to be available in 32-bit).
Didn't work though. Before I start messing with the source doe, is there some CMAKE property I need to set to switch between 32-bit and 64-bit mode? |
I think this Stack Overflow question should answer your 32/64-bit question. The third bullet is for Mac, and I think Unfortunately I'm not a CMake expert, so I'm just figuring these things out as we go. I use the CMake GUI on Windows. Also, my previous suggestion for the static cast was wrong, but the next try would be |
Adding Unfortunately, I came across a new set of errors involving SDL not being found.
This is actually the same issue I came across for OpenMW. It looks like you are using the same FindSDL2.cmake file that they were using. I discovered that there was a bug report to create a better solution that would not require such a file. Perhaps that could be implemented here? |
I'm reading through that OpenMW post and I'm wondering why this issue hasn't already been run into by other Mac users before. I don't think the problem is with finding SDL2main, because that only occurs at the linking stage. Your compiler error is from a missing type Does this help at all? https://stackoverflow.com/questions/28016258/using-homebrew-installed-sdl2-with-xcode. I think you would give those results from |
Turns out that I had SDL installed from a Pygame 1.9.1 download from years ago and the way it installed it was messing with this project. Once I deleted that, I successfully compiled OpenTESArena! The next problem is a failure to read the options.txt file, which I'll start looking into tomorrow. I've copied it over as the instructions say, so I'll need to figure out if something else is going on.
In the mean time, should I create a PR for the castings that we did earlier to get the app to build on macOS? |
That's good news that you've compiled it! I wonder why the executable wouldn't find the
You could do a pull request if you'd like. I would also add a comment there explaining why it's being done, like |
Only thing that really makes sense to me in the immediate sense is that the working directory for whatever reason isn't set correctly. Or permissions aren't set correctly to allow read access on the file, etc. Of course, this is assuming your install follows the folder structure in the post from @afritz1 above. The error comes from here: https://github.com/afritz1/OpenTESArena/blob/opentesarena-0.4.0/OpenTESArena/src/Utilities/File.cpp#L13 Which is being raised upon the attempt of opening the file in the first place. |
I don't understand what I was doing wrong earlier, but when I built the project in CLion instead of just from my Mac command line, I was able to successfully run Arena on macOS! I noticed an issue where the system mouse appeared above the game crosshairs, but otherwise the game worked without incident. Right now, it's basically a Unix executable file. Mac apps (.app) are actually special folders that macOS treats as an executable. The idea is that you have one app that has a bunch of files bundled inside; this is where the Unix executable, the options and data folders, etc are stored. I took a look into how OpenMW creates their Mac app files via CMake. Once it's in that format, I think I'd consider macOS supported, but of course subject to any bug reports. |
Great! We can start thinking about adding macOS support to the list of operating systems once we figure out the necessary changes to the CMake code. I'm not sure why the system mouse would be visible in-game. Maybe SDL2 doesn't behave the same on all platforms. |
Possibly, or alternatively macOS isn't willing to give it up. I figure I'll hold off on reporting Mac-specific issues until I make the changes to get it as a Mac app, and have instructions in the Readme so that people besides me can build it on that platform. |
Still wrestling with CMake bundling. I have most of the stuff working, including an icon on the Mac app. The biggest issue that we're going to have to overcome is how paths are handled. Mac apps have a structure like this:
As you can see, the data and options folders are supposed to be in a different directory from the compiled code. However, OpenTESArena is assuming that they are in the same directory. In order to get the app to run, I've had to modify, for instance, How should we go about handling this? My thought is maybe have a class that contains methods like Also, should the CMakeLists.txt file start with |
In this case, I guess the options path should have You're right that the project name should be |
|
That looks about right. I'm not positive if Actually, freeing it with |
Are there docs for |
I searched |
Oh, so I think the reason |
Sorry to bring bad news, but this has introduced an issue. Previous to this change one could set an absolute path for the ARENA installation. Now this is not possible, the path must be relative to the execution path. |
@abelsromero Are you sure that the issue is caused by this change? PR #81 only added |
Maybe there could be a boolean in |
Couldn't that be determined from the path defined in options.txt? If it
starts with a drive letter (x followed by a colon) or a leading forward
slash, then treat the path as absolute. Otherwise, relative.
…On Jul 12, 2017 5:05 PM, "Aaron" ***@***.***> wrote:
Maybe there could be a boolean in options.txt for whether ArenaPath is
absolute or relative to SDL_GetBasePath()? Is there a better way?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#74 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFcELNPr100D_uXKoTGiWmI7r4vCZEivks5sNTUmgaJpZM4ORh4Z>
.
|
That sounds like the better way. |
As a rule, I am never sure of anything 💃 , but I checked a build against the previous commit (ca8d126) and it worked with the absolute path, after that, it doesn't. It says that the X path is not a valid ARENA folder.
That's how I usually do it, I check agains some regex to check the type of path. In most projects I end up with a FileUtils or ResourceUtils class to encapsulate the location of different files. I do Java mostly, so it's a method that receives some strings and returns some reference like a DataStream, so I can even load data from HTTP or remote sources. Not sure what options C++ provides. |
This approach won't work on macOS or Linux, since absolute paths don't start with a letter. However, absolute paths begin with a leading slash, so I'm pretty sure you could check for that. For instance, the absolute path to my Arena installation is I imagine the code would basically be: If Windows, check for a drive letter. Else, check for a leading slash. If neither are present, it's a relative path. |
I suppose this could be implemented as something along the lines of: std::string platformName(SDL_GetPlatform());
if (platformName == "Windows")
{
// Drive letter...
}
else
{
// Leading forward slash...
} SDL_GetPlatform() should help us avoid ifdef's, since it looks like the platform names under "Remarks" are pretty dependable. |
|
Found that |
Seeing the comments I guess the issue has been confirmed by others. But just in case I double-checked in another machine and the problem with absolute paths happens. |
So I have my work in progress branch here. Currently, I have it so that when compiled on macOS, CMake will create a bundled macOS application, with icon and everything. I wouldn't consider this "ready" until it adds WildMidi support though, and that's got me stuck. If I don't add Wildmidi to the build path, everything works fine. But when I do add it, I get an immediate app crash:
Any ideas about this? |
We have a 0.6.0 macOS build on the releases page now. We can figure out the problem with WildMIDI in the future. It's probably an easy fix. |
This project currently has Windows and Linux builds for each release. I'd like to see macOS releases as well so that I can run OpenTESArena on my preferred platform.
The text was updated successfully, but these errors were encountered: