Warning, /graphics/krita/3rdparty/README.md is written in an unsupported language. File is not indexed.

0001 # CMake external projects to build krita's dependencies on Linux, Windows or OSX
0002 
0003 If you need to build Krita's dependencies for the following reasons:
0004 
0005 * you develop on Windows and aren't using build-tools/windows/build.cmd
0006 * you develop on OSX and aren't using the scripts in krita/packaging/osx or Homebrew
0007 * you want to build a generic, distro-agnostic version of Krita for Linux and aren't using the scripts in packaging/linux/appimage
0008 * you develop on Linux, but some dependencies aren't available for your distribution and aren't using the scripts in packaging/linux/appimage
0009 
0010 and you know what you're doing, you can use the following guide to build
0011 the dependencies that Krita needs.
0012 
0013 Using the scripts mentioned above is strongly preferred because that's what
0014 the Krita team uses to build the binaries on the binary factory
0015 (https://binary-factory.kde.org/).
0016 
0017 If you develop on Linux and your distribution has all dependencies available,
0018 
0019 YOU DO NOT NEED THIS GUIDE AND YOU SHOULD STOP READING NOW
0020 
0021 Otherwise you risk major confusion.
0022 
0023 **Important**: This document is not updated consistently. It may contain
0024 outdated information and missing steps. For clearer information on building
0025 Krita with the build scripts, check:
0026 https://docs.krita.org/en/untranslatable_pages/building_krita.html.
0027 
0028 ## Prerequisites
0029 
0030 Note: on all operating systems the entire procedure is done in a terminal window.
0031 
0032 1. git: https://git-scm.com/downloads. Make sure git is in your path
0033 2. CMake 3.3.2 or later: https://cmake.org/download/. Make sure cmake is in your path.
0034     * CMake 3.9 does not build Krita properly at the moment, please use 3.8 or 3.10 instead.
0035 3. Make sure you have a compiler:
0036     * Linux: gcc, minimum version 4.8
0037     * OSX: clang, you need to install xcode for this
0038     * Windows: LLVM MinGW (20220323 LLVM 14.0): https://github.com/mstorsjo/llvm-mingw/releases/download/20220323/llvm-mingw-20220323-ucrt-x86_64.zip
0039         * Install to something like C:\llvm-mingw; the full path must not contain any spaces.
0040             * Make sure the `bin` folder and the `x86_64-w64-mingw32\bin` folder
0041               are in your path. It might be a good idea to create a batch file
0042               which sets the path and start cmd.
0043         * If you want to use MSVC, check the script in `build-tools/windows`.
0044 
0045 4. On Windows, you will also need a release of Python 3.8 (not 3.7, probably not 3.9): https://www.python.org. Make sure to have that version of python.exe in your path. This version of Python will be used for two things: to configure Qt and to build the Python scripting module.  Make sure that this version of Python comes first in your path. Do not set PYTHONHOME or PYTHONPATH.
0046     * Make sure that your Python will have the correct architecture for the version you are trying to build. If building for 32-bit target, you need the 32-bit release of Python.
0047 
0048 5. On Windows, if you want to compile Qt with ANGLE support, you will need to install Windows 10 SDK and have 2 environment variables set:
0049     * `WindowsSdkDir` (typically set to `C:\Program Files (x86)\Windows Kits\10`)
0050     * `WindowsSdkVerBinPath` (typically set to `C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0`) where 10.0.18362.0 is the version of the Window 10 SDK.
0051 
0052     * Example:
0053         set "WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\10"
0054         set "WindowsSdkVerBinPath=%ProgramFiles(x86)%\Windows Kits\10\bin\10.0.18362.0"
0055 
0056 ## Setup your environment
0057 
0058 
0059 ## Prepare your directory layout
0060 
0061 1. Make a toplevel build directory, say $HOME/dev or c:\dev. We'll refer to this directory as BUILDROOT. You can use a variable for this, on WINDOWS %BUILDROOT%, on OSX and Linux $BUILDROOT. You will have to replace a bare BUILDROOT with $BUILDROOT or %BUILDROOT% whenever you copy and paste a command, depending on your operating system.
0062 
0063 2. Checkout krita in BUILDROOT
0064     ```
0065     cd BUILDROOT
0066     git clone git://anongit.kde.org/krita.git
0067     ```
0068 3. Create the build directory
0069     ```
0070     mkdir BUILDROOT/b
0071     ```
0072 4. Create the downloads directory
0073     ```
0074     mkdir BUILDROOT/d
0075     ```
0076 5. Create the install directory
0077     ```
0078     mkdir BUILDROOT/i
0079     ```
0080 
0081 ## Prepare the externals build
0082 
0083 1. Enter the BUILDROOT/b directory
0084 
0085 2. Run cmake:
0086 
0087     * Linux:
0088         ```
0089         export PATH=$BUILDROOT/i/bin:$PATH
0090         export PYTHONHOME=$BUILDROOT/i (only if you want to build your own python)
0091         cmake ../krita/3rdparty \
0092             -DINSTALL_ROOT=$BUILDROOT/i \
0093             -DEXTERNALS_DOWNLOAD_DIR=$BUILDROOT/d \
0094             -DCMAKE_INSTALL_PREFIX=BUILDROOT/i
0095         ```
0096 
0097     * OSX:
0098         ```
0099         export PATH=$BUILDROOT/i/bin:$PATH
0100         export PYTHONHOME=$BUILDROOT/i (only if you want to build your own python)
0101         cmake ../krita/3rdparty/  \
0102             -DCMAKE_INSTALL_PREFIX=$BUILDROOT/i \
0103             -DEXTERNALS_DOWNLOAD_DIR=$BUILDROOT/d  \
0104             -DINSTALL_ROOT=$BUILDROOT/i
0105         ```
0106 
0107     * Windows 32-bit / 64-bit:
0108 
0109         Note that the cmake command needs to point to your BUILDROOT like /dev/d, not c:\dev\d.
0110         ```
0111         set PATH=%BUILDROOT%\i\bin\;%BUILDROOT%\i\lib;%PATH%
0112         cmake ..\krita\3rdparty -DEXTERNALS_DOWNLOAD_DIR=/dev/d -DINSTALL_ROOT=/dev/i  -G "MinGW Makefiles"
0113         ```
0114 
0115         - If you want to build Qt and some other dependencies with parallel jobs, add
0116         `-DSUBMAKE_JOBS=<n>` to this cmake command where <n> is the number of jobs to
0117         run (if your PC has 4 CPU cores, you might want to set it to 5). For other jobs,
0118         you might need to manually add a -- -j N option, where N is the number of jobs.
0119 
0120         - If you don't have Windows 10 SDK and don't want to build Qt with ANGLE, add
0121         `-DQT_ENABLE_DYNAMIC_OPENGL=OFF` to the CMake command line args.
0122 
0123 3. Build the packages:
0124 
0125     On Windows:
0126     ```
0127     cmake --build . --config RelWithDebInfo --target ext_patch
0128     cmake --build . --config RelWithDebInfo --target ext_icoutils
0129     ```
0130 
0131     On OSX and Windows:
0132     ```
0133     cmake --build . --config RelWithDebInfo --target ext_gettext
0134     cmake --build . --config RelWithDebInfo --target ext_openssl
0135     ```
0136 
0137     On all operating systems:
0138     ```
0139     cmake --build . --config RelWithDebInfo --target ext_qt
0140     cmake --build . --config RelWithDebInfo --target ext_zlib
0141     cmake --build . --config RelWithDebInfo --target ext_boost
0142 
0143     Note about boost: check if the headers are installed into i/include/boost, but not into i/include/boost-1.61/boost
0144 
0145     cmake --build . --config RelWithDebInfo --target ext_eigen3
0146     cmake --build . --config RelWithDebInfo --target ext_exiv2
0147     cmake --build . --config RelWithDebInfo --target ext_fftw3
0148     cmake --build . --config RelWithDebInfo --target ext_jpeg
0149     cmake --build . --config RelWithDebInfo --target ext_lcms2
0150     cmake --build . --config RelWithDebInfo --target ext_ocio
0151     cmake --build . --config RelWithDebInfo --target ext_openexr
0152     ```
0153 
0154     OSX Note: You need to first build openexr; that will fail; then you need to set the rpath for the two utilities correctly, then try to build openexr again.
0155     ```
0156     install_name_tool -add_rpath $BUILD_ROOT/i/lib $BUILD_ROOT/b/ext_openexr/ext_openexr-prefix/src/ext_openexr-build/IlmImf/./b44ExpLogTable
0157     install_name_tool -add_rpath $BUILD_ROOT/i/lib $BUILD_ROOT/b/ext_openexr/ext_openexr-prefix/src/ext_openexr-build/IlmImf/./dwaLookups
0158     ```
0159 
0160     On All operating systems
0161     ```
0162     cmake --build . --config RelWithDebInfo --target ext_png
0163     cmake --build . --config RelWithDebInfo --target ext_tiff
0164     cmake --build . --config RelWithDebInfo --target ext_gsl
0165     cmake --build . --config RelWithDebInfo --target ext_vc
0166     cmake --build . --config RelWithDebInfo --target ext_libraw
0167     cmake --build . --config RelWithDebInfo --target ext_giflib
0168     cmake --build . --config RelWithDebInfo --target ext_openjpeg
0169     cmake --build . --config RelWithDebInfo --target ext_quazip
0170     ```
0171 
0172     On Linux (if you want to build your own SIP and PyQt instead of the system one)
0173     ```
0174     cmake --build . --config RelWithDebInfo --target ext_sip
0175     cmake --build . --config RelWithDebInfo --target ext_pyqt
0176     ```
0177 
0178     On Windows
0179     ```
0180     cmake --build . --config RelWithDebInfo --target ext_freetype
0181     cmake --build . --config RelWithDebInfo --target ext_poppler
0182     ```
0183 
0184     On Linux
0185     ```
0186     cmake --build . --config RelWithDebInfo --target ext_kcrash
0187     ```
0188 
0189     On Windows (if you want to include DrMingw for dumping backtrace on crash)
0190     ```
0191     cmake --build . --config RelWithDebInfo --target ext_drmingw
0192     ```
0193 
0194     On Windows (if you want to include Python scripting)
0195     ```
0196     cmake --build . --config RelWithDebInfo --target ext_python
0197     cmake --build . --config RelWithDebInfo --target ext_sip
0198     cmake --build . --config RelWithDebInfo --target ext_pyqt
0199     ```
0200 
0201     Troubleshooting: if you have problems with 'install' step
0202     of ext_sip or ext_pyqt, make sure you install it in single
0203     thread only (`mingw32-make -j1 install`). Otherwise, a
0204     race condition may happen in the post-install script and
0205     metadata generation will be started before actual libraries
0206     are installed.
0207 
0208     Linux Note: poppler should be buildable on Linux as well with a home-built freetype
0209     and fontconfig, but I don't know how to make fontconfig find freetype, and on
0210     Linux, fontconfig is needed for poppler. Poppler is needed for PDF import.
0211 
0212     OSX Note: In order to build fontconfig on macOS, you need to have pkg-config installed.
0213     You probably need homebrew for that... See http://macappstore.org/pkg-config/ .
0214     archives from: files.kde.org/krita/build/dependencies:
0215 
0216     On Windows and OSX
0217     ```
0218     cmake --build . --config RelWithDebInfo --target ext_kwindowsystem
0219     ```
0220 
0221 
0222 ## Build Krita
0223 
0224 1. Make a krita build directory:
0225     mkdir BUILDROOT/build
0226 2. Enter the BUILDROOT/build
0227 3. Configure the build:
0228 
0229     On Windows
0230     ```
0231     cmake ..\krita -G "MinGW Makefiles" -DBoost_DEBUG=OFF -DBOOST_INCLUDEDIR=c:\dev\i\include -DBOOST_DEBUG=ON -DBOOST_ROOT=c:\dev\i -DBOOST_LIBRARYDIR=c:\dev\i\lib -DCMAKE_INSTALL_PREFIX=c:\dev\i -DCMAKE_PREFIX_PATH=c:\dev\i -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=OFF -DKDE4_BUILD_TESTS=OFF -DHAVE_MEMORY_LEAK_TRACKER=OFF -Wno-dev -DDEFINE_NO_DEPRECATED=1
0232     ```
0233 
0234     On Linux
0235     ```
0236     cmake ../krita -DCMAKE_INSTALL_PREFIX=BUILDROOT/i -DDEFINE_NO_DEPRECATED=1 -DBUILD_TESTING=OFF -DKDE4_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo
0237 
0238     # Troubleshooting: if you built your own SIP and CMake fails to find it, please set
0239     #                  the following environment variable to the SIP installation directory:
0240     export PYTHONPATH=$BUILDROOT/i/sip/
0241 
0242     # If you also have KIO installed in the system, don't forget to disable it by bassing to cmake:
0243     # cmake -DCMAKE_DISABLE_FIND_PACKAGE_KF5KIO=true .
0244     ```
0245 
0246     On OSX
0247     ```
0248     cmake ../krita -DCMAKE_INSTALL_PREFIX=$BUILDROOT/i -DDEFINE_NO_DEPRECATED=1 -DBUILD_TESTING=OFF -DKDE4_BUILD_TESTS=OFF -DBUNDLE_INSTALL_DIR=$BUILDROOT/i/bin -DCMAKE_BUILD_TYPE=RelWithDebInfo
0249     ```
0250 
0251 4. Run the build:
0252 
0253     On Linux and OSX
0254     ```
0255     make
0256     make install
0257     ```
0258 
0259     On Windows (replace 4 with the number of jobs to run in parallel)
0260     ```
0261     cmake --build . --target install -- -j4
0262     ```
0263 
0264 6. Run krita:
0265 
0266     On Linux
0267     ```
0268     BUILDROOT/i/bin/krita
0269     ```
0270 
0271     On Windows
0272     ```
0273     BUILDROOT\i\bin\krita.exe
0274     ```
0275 
0276     On OSX
0277     ```
0278     BUILDROOT/i/bin/krita.app/Contents/MacOS/krita
0279     ```
0280 
0281 ## Packaging a Windows Build
0282 
0283 If you want to create a stripped down version of Krita to distribute, after building everything just run the packaging/windows/package-complete.cmd script.
0284 
0285 That script will copy the necessary files into the specified folder and leave out developer related files. After the script runs there will be two new ZIP files that contain a small portable version of Krita and a separate portable debug version.