Newbie questions about building OpenMW on a Mac

Everything about development and the OpenMW source code.
corristo
Posts: 495
Joined: 12 Aug 2011, 08:29

Re: How do I set up and build the project with Xcode?

Post by corristo »

Yep, @psi29a has a point, making CMake run successfully is a first mandatory step before getting any IDE working with the project.

I'd suggest not to run before_script.osx.sh bur rather use it as an example to build your own CMake command, because this script has some paths hardcoded, namely dependencies path, also it always uses Qt path from Homebrew so it's not going to work with downloadable SDK installation.

Here's a script I use locally:

Code: Select all

#!/bin/sh

DEPENDENCIES_ROOT="/path/to/unpacked/prebuilt/dependencies/openmw-deps"
QT_PATH="/Users/nkasyanov/Qt55/5.5/clang_64" # path to Qt

cmake \
-D CMAKE_PREFIX_PATH="$DEPENDENCIES_ROOT;$QT_PATH" \
-D CMAKE_OSX_DEPLOYMENT_TARGET="10.8" \
-D CMAKE_OSX_SYSROOT="macosx10.12" \
-D CMAKE_BUILD_TYPE=Debug \
-D DESIRED_QT_VERSION=5 \
-D BUILD_ESMTOOL=FALSE \
-D BUILD_MYGUI_PLUGIN=FALSE \
-D BUILD_OPENCS=TRUE \
-G"Unix Makefiles" \
..
(the script assumes that build directory is inside openmw checkout directory, tune accordingly if you prefer having build directory as sibling).

Please note that specifying CMAKE_PREFIX_PATH is crucial, without it CMake has no idea where to look for the dependencies.

Just in case, the most recent prebuilt dependencies: https://downloads.openmw.org/osx/depend ... af8112.zip.

Feel free to ask anything!
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: How do I set up and build the project with Xcode?

Post by Thunderforge »

What is DEPENDENCIES_ROOT="/path/to/unpacked/prebuilt/dependencies/openmw-deps" in your script? I didn't see anything about that in the instructions.

Also, if extra steps like these are necessary, could you please add them to the wiki?
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: How do I set up and build the project with Xcode?

Post by Thunderforge »

I figured out that it was referring to the openmw-deps-mac project. I tried building it following the instructions on the GitHub page, but ran into an issue with a missing file, which I filed an issue for. I tried downloading the zip file that corristo provided and ran this command:

Code: Select all

cmake -DCMAKE_PREFIX_PATH=/Users/Will/OpenSource/openmw-deps 
However, I got this error: "The source directory "/Users/Will/OpenSource/build" does not appear to contain CMakeLists.txt."
User avatar
psi29a
Posts: 5356
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: How do I set up and build the project with Xcode?

Post by psi29a »

There is an answer for that on google. :)
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: How do I set up and build the project with Xcode?

Post by Thunderforge »

With the help of people on IRC and the openmw-deps-mac GitHub page, I was able to build openmw-deps-mac. I am running this cmake command successfully, based on the contents of openmw/CI/before_script.osx.sh:

Code: Select all

cmake \
-D CMAKE_PREFIX_PATH="/Users/Will/OpenSource/openmw-deps;/usr/local/opt/[email protected]" \
-D CMAKE_OSX_DEPLOYMENT_TARGET="10.9" \
-D CMAKE_OSX_SYSROOT="macosx10.12" \
-D CMAKE_BUILD_TYPE=Release \
-D OPENMW_OSX_DEPLOYMENT=TRUE \
-D DESIRED_QT_VERSION=5 \
-D BUILD_ESMTOOL=FALSE \
-D BUILD_MYGUI_PLUGIN=FALSE \
-G"Unix Makefiles" ../openmw/
Once that goes successfully, I try running "make package", but get this error:

Code: Select all

[  0%] Building CXX object extern/oics/CMakeFiles/oics.dir/ICSChannel.cpp.o
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:60:25: error: 
      use of undeclared identifier 'SDL_GameController'
                typedef std::map<int, SDL_GameController*> JoystickInstanceMap;
                                      ^
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:60:44: error: 
      expected expression
                typedef std::map<int, SDL_GameController*> JoystickInstanceMap;
                                                         ^
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:97:46: error: 
      unknown type name 'SDL_ControllerDeviceEvent'
                void controllerAdded  (int deviceID, const SDL_Controlle...
                                                           ^
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:98:32: error: 
      unknown type name 'SDL_ControllerDeviceEvent'
                void controllerRemoved(const SDL_ControllerDeviceEvent &args);
                                             ^
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:112:48: error: 
      unknown type name 'SDL_ControllerButtonEvent'; did you mean
      'SDL_MouseButtonEvent'?
        void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &evt);
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~
                                               SDL_MouseButtonEvent
/Library/Frameworks/SDL.framework/Headers/SDL_events.h:143:3: note: 
      'SDL_MouseButtonEvent' declared here
} SDL_MouseButtonEvent;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:113:49: error: 
      unknown type name 'SDL_ControllerButtonEvent'; did you mean
      'SDL_MouseButtonEvent'?
        void buttonReleased(int deviceID, const SDL_ControllerButtonEvent &evt);
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~
                                                SDL_MouseButtonEvent
/Library/Frameworks/SDL.framework/Headers/SDL_events.h:143:3: note: 
      'SDL_MouseButtonEvent' declared here
} SDL_MouseButtonEvent;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:114:44: error: 
      unknown type name 'SDL_ControllerAxisEvent'
        void axisMoved(int deviceID, const SDL_ControllerAxisEvent &evt);
                                           ^
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:116:46: error: 
      unknown type name 'SDL_Scancode'; did you mean 'SDL_GrabMode'?
        void addKeyBinding(Control* control, SDL_Scancode key, Control::...
                                             ^~~~~~~~~~~~
                                             SDL_GrabMode
/Library/Frameworks/SDL.framework/Headers/SDL_video.h:873:3: note: 
      'SDL_GrabMode' declared here
} SDL_GrabMode;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:117:25: error: 
      unknown type name 'SDL_Scancode'; did you mean 'SDL_GrabMode'?
        bool isKeyBound(SDL_Scancode key) const;
                        ^~~~~~~~~~~~
                        SDL_GrabMode
/Library/Frameworks/SDL.framework/Headers/SDL_video.h:873:3: note: 
      'SDL_GrabMode' declared here
} SDL_GrabMode;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:125:31: error: 
      unknown type name 'SDL_Scancode'; did you mean 'SDL_GrabMode'?
        void removeKeyBinding(SDL_Scancode key);
                              ^~~~~~~~~~~~
                              SDL_GrabMode
/Library/Frameworks/SDL.framework/Headers/SDL_video.h:873:3: note: 
      'SDL_GrabMode' declared here
} SDL_GrabMode;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:131:9: error: 
      unknown type name 'SDL_Scancode'; did you mean 'SDL_GrabMode'?
        SDL_Scancode getKeyBinding(Control* control, ICS::Control::Contr...
        ^~~~~~~~~~~~
        SDL_GrabMode
/Library/Frameworks/SDL.framework/Headers/SDL_video.h:873:3: note: 
      'SDL_GrabMode' declared here
} SDL_GrabMode;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:137:38: error: 
      unknown type name 'SDL_Scancode'; did you mean 'SDL_GrabMode'?
        std::string scancodeToString(SDL_Scancode key);
                                     ^~~~~~~~~~~~
                                     SDL_GrabMode
/Library/Frameworks/SDL.framework/Headers/SDL_video.h:873:3: note: 
      'SDL_GrabMode' declared here
} SDL_GrabMode;
  ^
In file included from /Users/Will/OpenSource/openmw/extern/oics/ICSChannel.cpp:27:
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:181:26: error: 
      use of undeclared identifier 'SDL_Scancode'
        typedef std::map<SDL_Scancode, ControlKeyBinderItem> ControlsKey...
                         ^
/Users/Will/OpenSource/openmw/extern/oics/ICSInputControlSystem.h:223:15: error: 
      unknown type name 'SDL_Scancode'; did you mean 'SDL_GrabMode'?
            , SDL_Scancode key, Control::ControlChangingDirection direction);
              ^~~~~~~~~~~~
              SDL_GrabMode
/Library/Frameworks/SDL.framework/Headers/SDL_video.h:873:3: note: 
      'SDL_GrabMode' declared here
} SDL_GrabMode;
  ^
14 errors generated.
make[2]: *** [extern/oics/CMakeFiles/oics.dir/ICSChannel.cpp.o] Error 1
make[1]: *** [extern/oics/CMakeFiles/oics.dir/all] Error 2
make: *** [all] Error 2
I am guessing that it is looking for SDL, so I ran brew install sdl. However, I still get the same error. Looks like I'm stuck again.

And yes, I did Google the error for missing SDL_Scancode and other classes.
corristo
Posts: 495
Joined: 12 Aug 2011, 08:29

Re: How do I set up and build the project with Xcode?

Post by corristo »

Dependencies are indeed mentioned in the wiki: https://wiki.openmw.org/index.php?title ... pendencies

Also, I posted a link for prebuilt dependencies to not bother you with building them yourself. If you still want to build them, I suggest to pull today's changes from GitHub because I've merged C++11 support yesterday and it's crucial for current OpenMW upstream.

UPD: nevermind the last sentence, I've already written that on GitHub 8-)
Last edited by corristo on 02 Jul 2017, 13:55, edited 2 times in total.
corristo
Posts: 495
Joined: 12 Aug 2011, 08:29

Re: How do I set up and build the project with Xcode?

Post by corristo »

As far as I can judge from the build log, OpenMW picks up globally installed SDL.framework (/Library/Frameworks/SDL.framework), not the one from openmw-deps-mac, that almost certainly the reason of the failure you're experiencing.

UPD: if someone knows how to make CMake prioritize CMAKE_PREFIX_PATH over system paths, be my guest.
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: How do I set up and build the project with Xcode?

Post by Thunderforge »

I'm still interested in trying to contribute to OpenMW, so let's give it another go over the weekend.

I'm guessing it would be a bad idea to remove the globally installed SDL framework, and that it's updated with macOS. So updating it on that end is out.

Is there any way to run cmake and make in a "sandbox mode" like we can with the openmw-deps-mac project?
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: Newbie questions about building OpenMW on a Mac

Post by Thunderforge »

On IRC, JDGBOLT pointed out that OpenMW has a FindSDL2.cmake file checked in that has some macOS-specific code. One of the comments:

Code: Select all

    # Non-OS X framework versions expect you to also dynamically link to
    # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
    # seem to provide SDL2main for compatibility even though they don't
    # necessarily need it.
It seems like this may be the source of my problems. It looks like it was checking the SDL2DIR variable, so I set it to the Homebrew install location:

Code: Select all

export SDL2DIR=/usr/local/Cellar/sdl2/2.0.55
This unfortunately didn't solve my problems.

While investigating this, I found a bug report for the SDL2 project saying that there was no standard cmake file for SDL2, so every project had to create their own. The resolution was that a "standard" cmake file was created for SDL 2.0.4 (latest is 2.0.55). Perhaps someone more knowledgeable can change OpenMW to use this?
corristo
Posts: 495
Joined: 12 Aug 2011, 08:29

Re: Newbie questions about building OpenMW on a Mac

Post by corristo »

macOS doesn't ship SDL, at lest I've never had it it my /Library/Frameworks.

Also you don't need SDL from Homebrew, our dependency repo provides SDL.

Unfortunately there's no sandbox build for OpenMW yet. I'll try to make it build with SDL framework in /Library/Frameworks to see what we can do.
Post Reply