OpenToonz - An open-source full-featured 2D animation creation software
C
CMake/Linux: add an install target
Campbell Barton3158be2a42d9
diff --git a/doc/how_to_build_linux.md b/doc/how_to_build_linux.mdindex e204de346..549f98601 100644--- a/doc/how_to_build_linux.md+++ b/doc/how_to_build_linux.md@@ -65,7 +65,7 @@ zypper in boost-devel git cmake gcc-c++ freeglut-devel freetype2-devel glew-deve$ git clone https://github.com/opentoonz/opentoonz```-### Installation of the stuff directory+### Copying the stuff directoryTODO: some parts should really be installed in $prefix/ instead... and some other in various cache or user-local places.cf. https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html@@ -141,6 +141,21 @@ You can now run the application:```$ cd bin-$ LD_LIBRARY_PATH=image:toonzlib:toonzfarm/tfarm:tnzbase:tnztools:stdfx:sound:tnzcore:tnzext:colorfx:toonzqt toonz/OpenToonz_1.0+$ LD_LIBRARY_PATH=./lib/opentoonz:$LD_LIBRARY_PATH ./bin/OpenToonz_1.0```+### Performing a system installation++The steps above show how to run OpenToonz from the build directory,+however you may wish to install OpenToonz onto your system.++OpenToonz will install to `/opt/opentoonz` by default, to do this run:++```+$ sudo make install+```++Then you can launch OpenToonz by running `/opt/opentoonz/bin/opentoonz`.++You can change the installation path by modifying the `CMAKE_INSTALL_PREFIX` CMake variable.+diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txtindex a321fffe4..92964dd4f 100644--- a/toonz/sources/CMakeLists.txt+++ b/toonz/sources/CMakeLists.txt@@ -322,11 +322,15 @@ elseif(APPLE)elseif(UNIX)set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)- # For now put lib and runtime in the same path- # since its convenient to for launching.- set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)+ # Mirror relative bin/lib location for installation+ # so the generated shell script works in both cases.+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/opentoonz)+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/opentoonz)set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)++ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)+ set(CMAKE_INSTALL_PREFIX "/opt/opentoonz" CACHE PATH "OpenToonz install prefix" FORCE)+ endif()endif()if(MSVC AND MSVC_VERSION EQUAL 1800)diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txtindex c7d50c71d..f5d9b1dee 100644--- a/toonz/sources/toonz/CMakeLists.txt+++ b/toonz/sources/toonz/CMakeLists.txt@@ -405,4 +405,84 @@ if(APPLE)add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz_${VERSION}.app/Contents/Resources)add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/qss)add_custom_command(TARGET OpenToonz_${VERSION} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../install/SystemVar.ini ${CMAKE_CURRENT_BINARY_DIR}/OpenToonz_${VERSION}.app/Contents/Resources)+elseif(UNIX)+ # Setup files on Linux/Unix platform.+ # not essential since the binary can run in-place,+ # but useful for package managers.+ #+ # Note that its assumed the destination can be either+ # - /opt/opentoonz+ # - /usr+ install(+ TARGETS+ OpenToonz_${VERSION}+ DESTINATION bin+ )++ # Shell script that copies files to the home directory as needed+ # and sets the library preload path.+ file(WRITE ${CMAKE_BINARY_DIR}/bin/opentoonz+"#!/bin/sh+OPENTOONZ_BASE=\$(dirname \"\$0\")/..++if [ ! -d \$HOME/.config/OpenToonz ]; then+ mkdir -p \$HOME/.config/OpenToonz+fi++if [ ! -d \$HOME/.config/OpenToonz/stuff ]; then+ cp -r \$OPENTOONZ_BASE/share/opentoonz/stuff \$HOME/.config/OpenToonz+fi++if [ ! -e \$HOME/.config/OpenToonz/SystemVar.ini ]; then+ cat << EOF > $HOME/.config/OpenToonz/SystemVar.ini+[General]+OPENTOONZROOT="\$HOME/.config/OpenToonz/stuff"+OpenToonzPROFILES="\$HOME/.config/OpenToonz/stuff/profiles"+TOONZCACHEROOT="\$HOME/.config/OpenToonz/stuff/cache"+TOONZCONFIG="\$HOME/.config/OpenToonz/stuff/config"+TOONZFXPRESETS="\$HOME/.config/OpenToonz/stuff/projects/fxs"+TOONZLIBRARY="\$HOME/.config/OpenToonz/stuff/projects/library"+TOONZPROFILES="\$HOME/.config/OpenToonz/stuff/profiles"+TOONZPROJECTS="$HOME/.config/OpenToonz/stuff/projects"+TOONZROOT="\$HOME/.config/OpenToonz/stuff"+TOONZSTUDIOPALETTE="\$HOME/.config/OpenToonz/stuff/projects/studiopalette"+EOF+fi++export LD_LIBRARY_PATH=\${OPENTOONZ_BASE}/lib/opentoonz:\${LD_LIBRARY_PATH}++exec \$OPENTOONZ_BASE/bin/OpenToonz_${VERSION} \"\$@\"+")+ # only needed for executing without installing+ execute_process(COMMAND chmod +x ${CMAKE_BINARY_DIR}/bin/opentoonz)++ install(+ PROGRAMS+ ${CMAKE_BINARY_DIR}/bin/opentoonz+ DESTINATION bin+ )++ install(+ FILES+ "$<TARGET_FILE:tnzcore>"+ "$<TARGET_FILE:tnzbase>"+ "$<TARGET_FILE:toonzlib>"+ "$<TARGET_FILE:colorfx>"+ "$<TARGET_FILE:tnzext>"+ "$<TARGET_FILE:image>"+ "$<TARGET_FILE:sound>"+ "$<TARGET_FILE:toonzqt>"+ "$<TARGET_FILE:tnztools>"+ "$<TARGET_FILE:tnzstdfx>"+ "$<TARGET_FILE:tfarm>"+ DESTINATION lib/opentoonz+ )++ install(+ DIRECTORY+ ${CMAKE_SOURCE_DIR}/../../stuff+ DESTINATION share/opentoonz+ )+endif()+