diff --git a/doc/how_to_build_macosx.md b/doc/how_to_build_macosx.md index 591d4c8..069a129 100644 --- a/doc/how_to_build_macosx.md +++ b/doc/how_to_build_macosx.md @@ -6,85 +6,129 @@ - git - brew - Xcode -- cmake - - Version 3.2.2 confirmed to work. -- Qt - - http://download.qt.io/official_releases/qt/5.9/5.9.2/ - - qt-opensource-mac-x64-5.9.2.dmg -- boost - - http://www.boost.org/users/history/version_1_55_0.html (or later, though only 1.55.0 is supported) +- cmake (3.2.2 or later) +- Qt (5.9.2 or later) +- boost (1.55.0 or later) ## Building on MacOSX +### Download boost from https://boost.org -### 0. Install Qt 5.9 (Most recent is 5.9.2) +Download the .bz2 mac (unix if mac not specified) version 1_55_0 or later (last tested with 1_69_0) -### 1. Install Dependent Packages +Save for later step. -With homebrew, you can install them with following command. +### Download and install Xcode from Apple +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. + +Apple store usually provides for the most recent macOS version. For older versions, you will need to go to the Apple Developer site. + +After installing the application, you will need to start it in order to complete the installation. + +### Install Homebrew from https://brew.sh + +Check site for any changes in installation instructions, but they will probably just be this: + +1. Open a Terminal window +2. Execute the following statement: +``` +$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +### Install required software using brew + +In a Terminal window, execute the following statements: ``` -$ brew install glew lz4 libjpeg libpng lzo pkg-config libusb cmake git-lfs libmypaint +$ brew install glew lz4 libjpeg libpng lzo pkg-config libusb cmake git-lfs libmypaint qt +$ git lfs install ``` -Or, you should build and install them manually. +NOTE: This will install the latest version of QT which may not be compatible with older OS versions. +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. -### 2. Clone the Repository +### Set up OpenToonz repository +These steps will put the OpenToonz repository under /Users/yourlogin/Documents. ``` +$ cd ~/Documents #or where you want to store the repository# $ git clone https://github.com/opentoonz/opentoonz -cd opentoonz -git lfs pull +$ cd opentoonz +$ git lfs pull +$ cd thirdparty/boost +$ mv ~/Downloads/boost_1_69_0.tar.bz2 . #or whatever the boost filename you downloaded is# +$ tar xvjf boost_1_69_0.tar.bz2 +$ cd ../lzo +$ cp -r 2.03/include/lzo driver +$ cd ../tiff-4.0.3 +$ ./configure && make ``` -### (Optional) Create the stuff Directory +### Configure build for QT version -If the directory `/Applications/OpenToonz/OpenToonz_stuff` does not exist, enter the following command: +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 +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` +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` + +### Configure environment and Build OpenToonz + +1. Create the build directory with the following: ``` -$ sudo cp -r stuff /Applications/OpenToonz/OpenToonz_stuff +$ cd ~/Documents/opentoonz/toonz +$ mkdir build +$ cd build ``` -### 3. Build tiff in thirdparty +2. Set up build environment +To build from command line, do the following: ``` -$ cd thirdparty/tiff-4.0.3 -$ ./configure && make +$ CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.12.2 cmake ../sources #replace QT path with your installed QT version# +$ make ``` -### 4. Put Boost library into thirdpaty directory -The following assumes `boost_1_55_0.tar.bz2` was downloaded to `~/Downloads`. - +To build using Xcode, do the following: ``` -$ cd ../boost -$ mv ~/Downloads/boost_1_55_0.tar.bz2 . -$ tar xjvf boost_1_55_0.tar.bz2 +$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer +$ CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.12.2 cmake -G Xcode ../sources -B. #replace QT path with your installed QT version# ``` -### 5. Update the path to your Qt 5.9 install in opentoonz/toonz/sources/CMakeLists.txt line 160 or 172 -If using Qt 5.9.2, this is unnecessary. +- Open Xcode app and open project /Users/yourlogin/Documents/opentoonz/toonz/build/OpenToonz.xcodeproj +- Change `ALL_BUILD` to `OpenToonz` +- Start build with: Product -> Build -### 6. Copy the lzo header folder to the lzo driver directory + - 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: ``` -$ cd ../lzo -$ cp -r 2.03/include/lzo driver +/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/. +/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/ +Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure ``` -### 6. Build Everything Together +Side note: If you want the option to build by command line and Xcode, create a separate build directory for each. +### Create the stuff Directory + +If you have installed OpenToonz on the machine already, you can skip this. Otherwise, you need to create the stuff folder with the following: ``` -$ cd ../../toonz -$ mkdir build -$ cd build - CMAKE_PREFIX_PATH=~/Qt5.9.2/5.9.2/clang_64 cmake ../sources -$ make +$ cd ~/Documents/opentoonz +$ sudo mkdir /Applications/OpenToonz +$ sudo cp -r stuff /Applications/OpenToonz/OpenToonz_stuff +$ sudo chmod -R 777 /Applications/OpenToonz ``` -Please be patient as the install will take a while. - -### After Building +### Running the build +- If built using command line, run the following: ``` -$ open ./toonz/OpenToonz.app +$ open ~/Documents/opentoonz/build/toonz/OpenToonz.app ``` + +- If built using Xcode, do the following: + + - Open Scheme editor for OpenToonz: Product -> Scheme -> Edit Scheme + - Uncheck: Run -> Options -> Document Versions + - Run in Debug mode: Product -> Run + + - To open with command line or from Finder window, the application is found in `/Users/yourlogin/Documents/opentoonz/toonz/build/Debug/OpenToonz.app` diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt index 8a03d10..32a5828 100644 --- a/toonz/sources/CMakeLists.txt +++ b/toonz/sources/CMakeLists.txt @@ -280,7 +280,7 @@ macro(_find_toonz_library OUT_LIB_LIST IN_LIB_LIST) unset(COREPATH CACHE) # find しても cmake が走るときにはできていないので完全なパス名を生成して返すだけ if(BUILD_ENV_APPLE) - set(LIBPATH ${CMAKE_CURRENT_BINARY_DIR}/../${arg}/lib${arg}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(LIBPATH "\$") else() set(LIBPATH ${arg}) endif() diff --git a/toonz/sources/tnzbase/CMakeLists.txt b/toonz/sources/tnzbase/CMakeLists.txt index 3df02f3..f7cbc45 100644 --- a/toonz/sources/tnzbase/CMakeLists.txt +++ b/toonz/sources/tnzbase/CMakeLists.txt @@ -200,7 +200,7 @@ elseif(BUILD_ENV_APPLE) find_library(COCOA_LIB Cocoa) set(EXTRA_LIBS - ${CMAKE_CURRENT_BINARY_DIR}/../tnzcore/libtnzcore.dylib + "$" ${USB_LIB} ${TWAIN_LIB} ${IOKIT_LIB} diff --git a/toonz/sources/tnzext/CMakeLists.txt b/toonz/sources/tnzext/CMakeLists.txt index f44761d..f4c8f13 100644 --- a/toonz/sources/tnzext/CMakeLists.txt +++ b/toonz/sources/tnzext/CMakeLists.txt @@ -117,8 +117,8 @@ if(BUILD_ENV_MSVC) ) elseif(BUILD_ENV_APPLE) set(EXTRA_LIBS - ${CMAKE_CURRENT_BINARY_DIR}/../tnzcore/libtnzcore.dylib - ${CMAKE_CURRENT_BINARY_DIR}/../tnzbase/libtnzbase.dylib + "$" + "$" ) target_link_libraries(tnzext diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt index 067887b..4ea4287 100644 --- a/toonz/sources/toonz/CMakeLists.txt +++ b/toonz/sources/toonz/CMakeLists.txt @@ -1,4 +1,4 @@ -set(VERSION 1.3) +set(VERSION 1.3) set(MOC_HEADERS addfilmstripframespopup.h @@ -479,29 +479,29 @@ if(BUILD_ENV_APPLE) message(" ==> App Bundle: " ${loc}) message(" ==> Mach-o: " ${bin}) foreach(lib ${EXTRA_LIBS}) - message(" copy:" ${lib} "==>" ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz.app/Contents/MacOS/) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND cp ${lib} ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz.app/Contents/MacOS/) + message(" copy:" ${lib} "==>" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND cp ${lib} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endforeach() + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tcomposer) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tcleanup) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tconverter) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tfarmcontroller) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tfarmserver) + + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../Resources) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../install/SystemVar.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../Resources) + + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../../../qss) + add_custom_command(TARGET OpenToonz POST_BUILD COMMAND - ${CMAKE_INSTALL_NAME_TOOL} -add_rpath @executable_path/. ${bin} + ${CMAKE_INSTALL_NAME_TOOL} -add_rpath @executable_path/. ${bin} || true ) add_custom_command(TARGET OpenToonz POST_BUILD COMMAND - ${CMAKE_INSTALL_NAME_TOOL} -add_rpath ${CMAKE_INSTALL_RPATH} ${bin} + ${CMAKE_INSTALL_NAME_TOOL} -add_rpath ${CMAKE_INSTALL_RPATH} ${bin} || true ) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz.app/Contents/Resources) - - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz.app/Contents/Resources) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/qss) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../install/SystemVar.ini ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz.app/Contents/Resources) - - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tcomposer) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tcleanup) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tconverter) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tfarmcontroller) - add_custom_command(TARGET OpenToonz POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DEPENDS tfarmserver) elseif(BUILD_ENV_UNIXLIKE AND BUILD_TARGET_WIN) # Setup files on Windows platform while cross compilation. diff --git a/toonz/sources/toonzfarm/tfarm/CMakeLists.txt b/toonz/sources/toonzfarm/tfarm/CMakeLists.txt index afcbbed..833c4dc 100644 --- a/toonz/sources/toonzfarm/tfarm/CMakeLists.txt +++ b/toonz/sources/toonzfarm/tfarm/CMakeLists.txt @@ -45,9 +45,9 @@ if(BUILD_ENV_MSVC) ) elseif(BUILD_ENV_APPLE) set(EXTRA_LIBS - ${CMAKE_CURRENT_BINARY_DIR}/../../tnzcore/libtnzcore.dylib - ${CMAKE_CURRENT_BINARY_DIR}/../../tnzbase/libtnzbase.dylib - ${CMAKE_CURRENT_BINARY_DIR}/../../toonzlib/libtoonzlib.dylib + "$" + "$" + "$" ) add_dependencies(tfarm tnzcore tnzbase toonzlib tnzext) elseif(BUILD_ENV_UNIXLIKE) diff --git a/toonz/sources/toonzlib/CMakeLists.txt b/toonz/sources/toonzlib/CMakeLists.txt index e09e470..ca5f21c 100644 --- a/toonz/sources/toonzlib/CMakeLists.txt +++ b/toonz/sources/toonzlib/CMakeLists.txt @@ -361,9 +361,9 @@ if(BUILD_ENV_MSVC) ) elseif(BUILD_ENV_APPLE) set(EXTRA_LIBS - ${CMAKE_CURRENT_BINARY_DIR}/../tnzcore/libtnzcore.dylib - ${CMAKE_CURRENT_BINARY_DIR}/../tnzbase/libtnzbase.dylib - ${CMAKE_CURRENT_BINARY_DIR}/../tnzext/libtnzext.dylib + "$" + "$" + "$" ${USB_LIB} ${MYPAINT_LIB_LDFLAGS} )