So I'm finally going to attempt to build OpenMW on a Mac. The thing is, I have never worked with C++ before (but plenty of Java and Python experience), and I'm having a hard time figuring out how to build it.
I started by looking at the macOS section of the Development Environment Setup page on our wiki. This was clear enough; I installed Xcode 8 from the App Store (and I think the command line tools got installed with it?). I then installed homebrew and used it to install cmake and pkg-config. Next I installed Qt, but chose to do it through the package on the Qt website.
All of that went well, but I was having trouble going from there. I launched Xcode and clicked "Check out an existing project". I pasted the Git URL into the text field, then was prompted with branches (I chose master). Then it prompted me to save it and I selected a location. After it finished downloading, the folder opened in the Finder. I clicked the "Finish" button in Xcode, but then I wasn't prompted with any screens. I tried going to File -> Open, but was told that" Xcode does not support opening folders without a project or workspace."
I'm kind of stuck at this point and am not sure what to do. Does anyone know what more I need to do to set up and build OpenMW in Xcode?
Newbie questions about building OpenMW on a Mac
- Thunderforge
- Posts: 503
- Joined: 06 Jun 2017, 05:57
Newbie questions about building OpenMW on a Mac
Last edited by Thunderforge on 08 Jul 2017, 00:49, edited 1 time in total.
Re: How do I set up and build the project with Xcode?
Seeing your description matches mine I feel obligated to give it a try and help. I work with Java and I've been doing some c++ stuff lately, mainly, small file parsing programs and compiling OpenTES on Windows. Havn't tried on Mac though, but seems pretty straight forward.Thunderforge wrote: ↑29 Jun 2017, 00:41 So I'm finally going to attempt to build OpenMW on a Mac. The thing is, I have never worked with C++ before (but plenty of Java and Python experience), and I'm having a hard time figuring out how to build it.
I think the problem is you're trying to use Xcode as IDE, but the instructions in the site are solely command line instructions for compiling the project. The whole compile process is done using good-old 'make' command, it's a very similar tool to Java Ant.
So, following the instructions in the shell should be fine to get the final binary.
A couple things that can help you:
1. cmake is a 'make' generation tool. It will look for env variables to set up and create the final make files you need for the compilation. Unless you change libraries, paths, or delete the `build` directory, you only need to run it once. Also, you can use a graphical version if you have problems using it in the command line https://cmake.org/download/. It will highlight any problem with env vars not found and allow you to set them manually. For example, I am not sure the $PATH_TO_DEPENDENCIES_DIR;$PATH_TO_QT_INSTALLATION vars that appear in the wiki as set by Homebrew.
2. Patience. We Java ppl have forgotten about lots of small details related to building real binaries
For IDE I'be been using "Eclipse for C/C++" or even IntelliJ (when using the C++ gradle plugin) but still compiling/testing using `make` on the shell. I really wish CLion had a community edition :/ I find that there are not many good C/C++ IDEs for someone that needs a free alternative to work on projects from time to time.
- psi29a
- Posts: 5361
- 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?
It seems that the IDE of choice for OpenMW devs has been:
QTCreator
Clion
Eclipse
There have been those that have used Code::Blocks and XCode as well.
For XCode, you'll need to run cmake with -G to generate XCode xompatible project files.
Then point XCode to that build directory.
QTCreator
Clion
Eclipse
There have been those that have used Code::Blocks and XCode as well.
For XCode, you'll need to run cmake with -G to generate XCode xompatible project files.
Code: Select all
mkdir build
cd build
cmake -G Xcode ../openmw
Re: How do I set up and build the project with Xcode?
I would like to add that kdevelop also works perfectly fine for openmw development
- Thunderforge
- Posts: 503
- Joined: 06 Jun 2017, 05:57
Re: How do I set up and build the project with Xcode?
I wouldn't mind trying Clion (Intellij IDEA is my primary Java IDE), but I'm not sure I'm ready to pay for it. I may try Eclipse if I can't get Xcode to work out.
I tried this and I get the following error:psi29a wrote: ↑29 Jun 2017, 08:03 For XCode, you'll need to run cmake with -G to generate XCode xompatible project files.
Then point XCode to that build directory.Code: Select all
mkdir build cd build cmake -G Xcode ../openmw
Code: Select all
-- Using Qt4
CMake Error at /usr/local/Cellar/cmake/3.8.2/share/cmake/Modules/FindQt4.cmake:1318 (message):
Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
CMakeLists.txt:136 (find_package)
- psi29a
- Posts: 5361
- 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?
Try adding: -D DESIRED_QT_VERSION=5
There are other options as well that might help for XCode, you'll have to google around a bit.
We default to Qt4 because Qt5 has a bug with OpenGL context being used within Qt, but this is related to OpenMW-CS and not to the launcher or openmw itself.
Code: Select all
mkdir build
cd build
cmake -G Xcode -D DESIRED_QT_VERSION=5 ../openmw
We default to Qt4 because Qt5 has a bug with OpenGL context being used within Qt, but this is related to OpenMW-CS and not to the launcher or openmw itself.
- Thunderforge
- Posts: 503
- Joined: 06 Jun 2017, 05:57
Re: How do I set up and build the project with Xcode?
That resulted in this:
Code: Select all
-- Configuring OpenMW...
-- Using Qt5
CMake Error at CMakeLists.txt:138 (find_package):
By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Widgets", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Widgets" with
any of the following names:
Qt5WidgetsConfig.cmake
qt5widgets-config.cmake
Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
"Qt5Widgets_DIR" to a directory containing one of the above files. If
"Qt5Widgets" provides a separate development package or SDK, be sure it has
been installed.
Code: Select all
export Qt5Widgets_DIR=/Users/Will/Qt5.5.1
- psi29a
- Posts: 5361
- 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?
Have you tried running our OSX scripts from /CI directory? We use these to setup what we need to build an OpenMW on macOS on Travis-CI.
- Thunderforge
- Posts: 503
- Joined: 06 Jun 2017, 05:57
Re: How do I set up and build the project with Xcode?
I tried running before_install.osx.sh followed by before_script.osx.sh, but it didn't make a difference unfortunately. I also tried uninstalling the packaged version of Qt and ran "brew install [email protected]" as described in the instructions, but it didn't make a difference.
I'm open to any new ideas with Xcode. I also tried switching to Eclipse (and created a new thread based on questions I had with getting that to work).
- psi29a
- Posts: 5361
- 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?
I don't believe the problem is with your IDE, it is that CMake can't find your Qt installation.