Difference between revisions of "How to build VCMI (macOS)"

From VCMI Project Wiki
Jump to: navigation, search
(Update instruction for most recent changes)
Line 1: Line 1:
Installing XCode
+
= Installing dependencies =
----------------
+
===== Installing XCode =====
 
App Store -> XCode
 
App Store -> XCode
 
Launch it after the installation to agree with it's license terms.
 
Launch it after the installation to agree with it's license terms.
  
Installing Homebrew
+
===== Installing [https://brew.sh/ Homebrew] =====
-------------------
 
 
<pre>
 
<pre>
 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
</pre>
 
</pre>
  
Installing dependencies available in Homebrew
+
===== Installing dependencies using Homebrew =====
---------------------------------------------
 
 
<pre>
 
<pre>
brew install git smpeg2 innoextract cmake libpng freetype sdl2 sdl2_ttf sdl2_image boost
+
brew install git cmake sdl2 sdl2_ttf sdl2_image boost qt5 ffmpeg
 
brew install sdl2_mixer --with-smpeg2  
 
brew install sdl2_mixer --with-smpeg2  
 
</pre>
 
</pre>
  
Installing Sparkle
+
= Building VCMI in command line with Makefiles =
------------------
+
===== Getting and configuring VCMI =====
<pre>
 
wget https://github.com/sparkle-project/Sparkle/releases/download/1.11.0/Sparkle-1.11.0.tar.bz2
 
mkdir sparkle && cd sparkle
 
tar -xf ../Sparkle-1.11.0.tar.bz2
 
sudo mv Sparkle.framework /Library/Frameworks/
 
cd .. && rm -rf sparkle
 
</pre>
 
 
 
Getting and configuring VCMI
 
----------------------------
 
 
<pre>
 
<pre>
 +
# You can choose any directory
 +
mkdir ~/DEV && cd ~/DEV
 
# Clone VCMI with all submodules
 
# Clone VCMI with all submodules
 
git clone -b develop --depth 1 --recursive  https://github.com/vcmi/vcmi.git
 
git clone -b develop --depth 1 --recursive  https://github.com/vcmi/vcmi.git
cd vcmi
+
# Creating directory for build
 
mkdir build && cd build
 
mkdir build && cd build
cmake -G "Unix Makefiles" .. -DENABLE_LAUNCHER=OFF -DCMAKE_BUILD_TYPE=Release -Wno-devc
+
cmake ../vcmi -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -Wno-devc
cd ..
 
 
</pre>
 
</pre>
  
Building OSX-specific stuff
+
===== Building and packaging VCMI =====
---------------------------
 
 
<pre>
 
<pre>
xcodebuild -project osx/osx-vcmibuilder/vcmibuilder.xcodeproj/ -configuration Release
+
cd ~/DEV/build
mv osx/osx-vcmibuilder/build/Release/vcmibuilder.app osx/vcmibuilder.app
+
# Start build using cmake
</pre>
+
cmake --build . -- -j 4
 +
# Or you can as well use simple
 +
# make -j 4
  
Building VCMI
+
# When build is completed you can trigger packaging into DMG
-------------
+
cpack
<pre>
+
# After file named such as "vcmi-0.99.dmg" will be created
cd build
 
make -j4
 
cd ..
 
 
</pre>
 
</pre>
  
Running VCMI
+
===== Running VCMI =====
------------
+
You can run VCMI from DMG, but after "cpack" is finished you can run unpacked executables as well
Go to bin and launch vcmiclient; alternatively
 
<pre>
 
bin/vcmiclient.app/Contents/MacOS/vcmiclient
 
</pre>
 
 
 
 
 
 
 
== Troubleshooting ==
 
 
 
In case the App crashes instantly with an error like:
 
<pre>
 
dyld: Library not loaded: /usr/local/lib/libSDL-1.2.0.dylib
 
  Referenced from: /usr/local/lib/libavcodec.56.dylib
 
  Reason: image not found
 
Trace/BPT trap: 5
 
</pre>
 
  
do
+
Go to "build" and launch executable directly; alternatively
 
<pre>
 
<pre>
brew install sdl
+
~/build/build/VCMI.app/Contents/MacOS/vcmilauncher
 +
~/build/build/VCMI.app/Contents/MacOS/vcmiclient
 +
~/build/build/VCMI.app/Contents/MacOS/vcmiserver
 
</pre>
 
</pre>

Revision as of 03:36, 9 August 2017

Installing dependencies

Installing XCode

App Store -> XCode Launch it after the installation to agree with it's license terms.

Installing Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing dependencies using Homebrew
brew install git cmake sdl2 sdl2_ttf sdl2_image boost qt5 ffmpeg
brew install sdl2_mixer --with-smpeg2 

Building VCMI in command line with Makefiles

Getting and configuring VCMI
# You can choose any directory
mkdir ~/DEV && cd ~/DEV
# Clone VCMI with all submodules
git clone -b develop --depth 1 --recursive  https://github.com/vcmi/vcmi.git
# Creating directory for build
mkdir build && cd build
cmake ../vcmi -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -Wno-devc
Building and packaging VCMI
cd ~/DEV/build
# Start build using cmake
cmake --build . -- -j 4
# Or you can as well use simple
# make -j 4

# When build is completed you can trigger packaging into DMG
cpack
# After file named such as "vcmi-0.99.dmg" will be created
Running VCMI

You can run VCMI from DMG, but after "cpack" is finished you can run unpacked executables as well

Go to "build" and launch executable directly; alternatively

~/build/build/VCMI.app/Contents/MacOS/vcmilauncher
~/build/build/VCMI.app/Contents/MacOS/vcmiclient
~/build/build/VCMI.app/Contents/MacOS/vcmiserver