Keisuke Ogaki 9cb85e
Grimaud 7c3890
# Setting Up the Development Environment on MacOSX
Grimaud 7c3890
Grimaud 7c3890
## Necessary Software
Grimaud 7c3890
Grimaud 7c3890
- git
Grimaud 7c3890
- brew
Grimaud 7c3890
- Xcode
John Dancel 9b3928
- cmake (3.2.2 or later)
John Dancel 9b3928
- Qt (5.9.2 or later)
John Dancel 9b3928
- boost (1.55.0 or later)
Grimaud 7c3890
Grimaud 7c3890
## Building on MacOSX
John Dancel 9b3928
### Download boost from https://boost.org
Grimaud 7c3890
John Dancel 9b3928
Download the .bz2 mac (unix if mac not specified) version 1_55_0 or later (last tested with 1_69_0)
Keisuke Ogaki 9cb85e
John Dancel 9b3928
Save for later step.
Keisuke Ogaki 9cb85e
John Dancel 8e63fa
### Download and install Xcode from Apple
Grimaud 7c3890
John Dancel 8e63fa
When downloading Xcode, you should use the appropriate version for your OS version.  You can refer to the Version Comparison Table on https://en.wikipedia.org/wiki/Xcode to find out which version you should use.
John Dancel 9b3928
John Dancel 9b3928
Apple store usually provides for the most recent macOS version.  For older versions, you will need to go to the Apple Developer site.
John Dancel 9b3928
John Dancel 8e63fa
After installing the application, you will need to start it in order to complete the installation.
John Dancel 8e63fa
John Dancel 9b3928
### Install Homebrew from https://brew.sh
John Dancel 9b3928
John Dancel 9b3928
Check site for any changes in installation instructions, but they will probably just be this:
John Dancel 9b3928
John Dancel 9b3928
1. Open a Terminal window
John Dancel 9b3928
2. Execute the following statement:
John Dancel 9b3928
```
John Dancel 9b3928
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
John Dancel 9b3928
```
John Dancel 9b3928
John Dancel 9b3928
### Install required software using brew
John Dancel 9b3928
John Dancel 9b3928
In a Terminal window, execute the following statements:
Grimaud 7c3890
```
John Dancel 9b3928
$ brew install glew lz4 libjpeg libpng lzo pkg-config libusb cmake git-lfs libmypaint qt
John Dancel 9b3928
$ git lfs install
Grimaud 7c3890
```
Grimaud 7c3890
John Dancel 9b3928
NOTE: This will install the latest version of QT which may not be compatible with older OS versions.
Keisuke Ogaki 9cb85e
John Dancel c0795e
If you cannot use the most recent version, download the online installer from https://www.qt.io/download and install the appropriate `macOS` version (min 5.9.2).  If installing via this method, be sure to install the `Qt Script (Deprecated)` libraries.
Keisuke Ogaki 9cb85e
John Dancel 9b3928
### Set up OpenToonz repository
Grimaud 7c3890
John Dancel 9b3928
These steps will put the OpenToonz repository under /Users/yourlogin/Documents.
Grimaud 7c3890
```
John Dancel 9b3928
$ cd ~/Documents   #or where you want to store the repository#
Grimaud 7c3890
$ git clone https://github.com/opentoonz/opentoonz
John Dancel 9b3928
$ cd opentoonz
John Dancel 9b3928
$ git lfs pull
John Dancel 9b3928
$ cd thirdparty/boost
John Dancel 662ad3
$ mv ~/Downloads/boost_1_69_0.tar.bz2 .  #or whatever the boost filename you downloaded is#
John Dancel 662ad3
$ tar xvjf boost_1_69_0.tar.bz2
John Dancel 9b3928
$ cd ../lzo
John Dancel 9b3928
$ cp -r 2.03/include/lzo driver
John Dancel 9b3928
$ cd ../tiff-4.0.3
John Dancel 9b3928
$ ./configure && make
Grimaud 7c3890
```
Grimaud 7c3890
John Dancel 9b3928
### Configure build for QT version
John Dancel 9b3928
John Dancel c0795e
Edit the `/Users/yourlogin/Documents/opentoonz/toonz/sources/CMakeLists.txt` file at line 160 (64bit OS) or 172 (32bit OS) and modify the root path for the QT lib directory
Grimaud 7c3890
John Dancel c0795e
If you installed QT using `brew` , you can get the version and path to use with: `$ brew info qt`.  The lib path will look something like this: `/usr/local/Cellar/qt/5.12.2/lib`
John Dancel c0795e
If you downloaded the QT installer and installed to `/Users/yourlogin/Qt`, your lib path may look something like this: `~/Qt/5.12.2/clang_64/lib` or `~/Qt/5.12.2/clang_32/lib`
Grimaud 7c3890
John Dancel 9b3928
### Configure environment and Build OpenToonz
John Dancel 9b3928
John Dancel 9b3928
1. Create the build directory with the following:
Grimaud 7c3890
```
John Dancel 9b3928
$ cd ~/Documents/opentoonz/toonz
John Dancel 9b3928
$ mkdir build
John Dancel 9b3928
$ cd build
Grimaud 7c3890
```
Grimaud 7c3890
John Dancel 9b3928
2. Set up build environment
Grimaud 7c3890
John Dancel 9b3928
To build from command line, do the following:
Grimaud 7c3890
```
John Dancel 9b3928
$ CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.12.2 cmake ../sources  #replace QT path with your installed QT version#
John Dancel 9b3928
$ make
Grimaud 7c3890
```
Grimaud 7c3890
John Dancel 8e63fa
To build using Xcode, do the following:
Grimaud 7c3890
```
John Dancel 9b3928
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
John Dancel 9b3928
$ CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.12.2 cmake -G Xcode ../sources -B.  #replace QT path with your installed QT version#
Grimaud 7c3890
```
Grimaud 7c3890
John Dancel 9b3928
- Open Xcode app and open project /Users/yourlogin/Documents/opentoonz/toonz/build/OpenToonz.xcodeproj
John Dancel 9b3928
- Change `ALL_BUILD` to `OpenToonz`
John Dancel 9b3928
- Start build with: Product -> Build
Jeremy Bullock 5ffb5d
John Dancel 9b3928
    - NOTE about rebuilding in Xcode: The initial build should succeed without any errors.  There after, the build will succeed but the following 3 errors can be ignored:
Jeremy Bullock 5ffb5d
Jeremy Bullock 5ffb5d
```
John Dancel 9b3928
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: for: /Users/yourlogin/Documents/opentoonz/toonz/build/toonz/Debug/OpenToonz.app/Contents/MacOS/OpenToonz (for architecture x86_64) option "-add_rpath @executable_path/." would duplicate path, file already has LC_RPATH for: @executable_path/.
John Dancel 9b3928
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: for: /Users/yourlogin/Documents/opentoonz/toonz/build/toonz/Debug/OpenToonz.app/Contents/MacOS/OpenToonz (for architecture x86_64) option "-add_rpath /usr/local/Cellar/qt/5.12.2/lib/" would duplicate path, file already has LC_RPATH for: /usr/local/Cellar/qt/5.12.2/lib/
John Dancel 9b3928
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
Jeremy Bullock 5ffb5d
```
Jeremy Bullock 5ffb5d
John Dancel 8e63fa
Side note: If you want the option to build by command line and Xcode, create a separate build directory for each.
John Dancel c0795e
John Dancel 9b3928
### Create the stuff Directory
Grimaud 7c3890
John Dancel 9b3928
If you have installed OpenToonz on the machine already, you can skip this.  Otherwise, you need to create the stuff folder with the following:
Grimaud 7c3890
```
John Dancel 9b3928
$ cd ~/Documents/opentoonz
John Dancel 5e857d
$ sudo mkdir /Applications/OpenToonz
John Dancel 9b3928
$ sudo cp -r stuff /Applications/OpenToonz/OpenToonz_stuff
John Dancel 5e857d
$ sudo chmod -R 777 /Applications/OpenToonz
Grimaud 7c3890
```
Grimaud 7c3890
John Dancel 9b3928
### Running the build
Grimaud 7c3890
John Dancel c0795e
- If built using command line, run the following:
Grimaud 7c3890
```
John Dancel 9b3928
$ open ~/Documents/opentoonz/build/toonz/OpenToonz.app
Grimaud 7c3890
```
John Dancel 9b3928
John Dancel 9b3928
- If built using Xcode, do the following:
John Dancel 9b3928
John Dancel 9b3928
    - Open Scheme editor for OpenToonz: Product -> Scheme -> Edit Scheme
John Dancel 662ad3
    - Uncheck: Run -> Options -> Document Versions
John Dancel 9b3928
    - Run in  Debug mode: Product -> Run
John Dancel 9b3928
John Dancel 9b3928
    - To open with command line or from Finder window, the application is found in `/Users/yourlogin/Documents/opentoonz/toonz/build/Debug/OpenToonz.app`