Keisuke Ogaki 9cb85e
artisteacher aa1f0e
# Setting Up the Development Environment on macOS
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
artisteacher aa1f0e
## Building on macOS
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
```
artisteacher f69e2d
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
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
```
shun-iwasawa ed0e4e
$ brew install glew lz4 libjpeg libpng lzo pkg-config libusb cmake git-lfs libmypaint qt boost
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
artisteacher aa1f0e
### Remove incompatible symbolic directory
artisteacher aa1f0e
Check to see if this symbolic glew directory exists. If so, remove it:
artisteacher aa1f0e
```
artisteacher aa1f0e
$ ls -l /usr/local/lib/cmake/glew
artisteacher aa1f0e
$ rm /usr/local/lib/cmake/glew
artisteacher aa1f0e
```
artisteacher aa1f0e
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
shun-iwasawa ed0e4e
$ cd thirdparty/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
shun-iwasawa ed0e4e
If you downloaded and installed boost from https://boost.org instead of homebrew, move the package under `thirdparty/boost` as follows: 
shun-iwasawa ed0e4e
```
shun-iwasawa ed0e4e
$ cd thirdparty/boost
shun-iwasawa ed0e4e
$ mv ~/Downloads/boost_1_72_0.tar.bz2 .   #or whatever the boost filename you downloaded is#
shun-iwasawa ed0e4e
$ tar xvjf boost_1_72_0.tar.bz2
shun-iwasawa ed0e4e
```
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
```
shun-iwasawa ed0e4e
$ cmake ../sources -DQT_PATH='/usr/local/opt/qt/lib'  #replace QT path with your installed QT version#
John Dancel 9b3928
$ make
Grimaud 7c3890
```
shun-iwasawa ed0e4e
- If you downloaded the QT installer and installed to `/Users/yourlogin/Qt` instead of by using homebrew, 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 8e63fa
To build using Xcode, do the following:
Grimaud 7c3890
```
John Dancel 9b3928
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
shun-iwasawa ed0e4e
$ cmake -G Xcode ../sources -B. -DQT_PATH='/usr/local/opt/qt/lib' -DWITH_TRANSLATION=OFF   #replace QT path with your installed QT version#
Grimaud 7c3890
```
shun-iwasawa ed0e4e
- Note that the option `-DWITH_TRANSLATION=OFF` is needed to avoid error when using XCode 12+ which does not allow to add the same source to multiple targets.
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
MrBlockCat 533ef8
    - 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`