Dev:Doc/Building Blender/Linux/cmake
3. Compile Blender with CMake
Installing CMake
Install CMake from your package manager.
Automatic CMake Setup
If you're not interested in manually setting up CMake build directory, configuring, building and installing in separate steps, we provide a convenience makefile in Blender's source directory which sets up CMake for you.
cd ~/blender-git/blender
make
Once the build finishes you'll get a message like..
Blender successfully built, run from: /home/me/blender-git/build_linux/bin/blender
Updating your local checkout and rebuilding is as simple as:
cd ~/blender-git/blender
make update
make
There are some pre-defined build targets:
- make - some are turned off by default because they can be difficult to correctly configure for newer developers and aren't essential to use & develop Blender in most cases.
- make lite - the quickest way to get a Blender build up & running, can also help to avoid installing a lot of dependencies if you don't need video-codecs, physics-sim & cycles rendering.
- make full - this makes a complete build with all options enabled, matching the releases on blender.org.
For a full list of the optional targets type...
make help
Manual CMake Setup
+ Manual CMake Setup (optional)
If you want to have more control over your build configuration or have multiple build directories for a single source directory. You can follow these steps. Typically useful for developers, who built frequently. Preparing CMake's directoryNow you have to choose a location for CMake build files, currently in-source builds in Blender aren't supported. Out-of-source build By doing an "out-of-source" build you create a CMake's directory aside from mkdir ~/blender-git/build
cd ~/blender-git/build
cmake ../blender
This will generate makefiles in the build directory (
Editing CMake ParametersNote that CMake should detect correct parameters so you shouldn't need change defaults to simply to compile blender, this is only if you want to change defaults, make a debug build, disable features etc, You can modify the build parameters in different ways:
cmake ../blender \
-DCMAKE_INSTALL_PREFIX=/opt/blender \
-DWITH_INSTALL_PORTABLE=OFF \
-DWITH_BUILDINFO=OFF \
-DWITH_GAMEENGINE=OFF
Building BlenderAfter changes have been done and you have generated the makefiles, you can compile using the make command inside the build directory: cd ~/blender-git/build
make
make install
テンプレート:Dev:Doc/Building Blender/MakeJobs Also notice the install target is used, this will copy scripts and documentation into ~/blender-git/build/bin For future builds you can simply update the repository and re-run make. cd ~/blender-git/blender
git pull --rebase
git submodule foreach git pull --rebase origin master
cd ~/blender-git/build
make
make install
Static LinkingIf you want to share your build with others you may want to include libraries with Blender (statically linked libraries).
Static Linking Each Library:
TODO: other libs? |
Optimize Rebuilds
+ Optimize Rebuilds (optional)
Now that you can build blender and run blender, there are changes you can make which greatly increase the speed of build times. Use one of the CMake configuration editors (ccmake or cmake-gui), see Editing CMake Parameters For really fast rebuilds you can disable Every option with the WITH_ prefix, except for WITH_PYTHON which is needed for the UI. This speeds up linking and gives a smaller binary. Remove the files created by make install since they will become stale. However, blender still needs to be able to find its scripts or you will have a very minimalist looking interface. This can be solved by linking the source directory to your blender binary path so copying isn't needed and scripts are always up to date. rm -r ~/blender-git/build/bin/*.*
ln -s ~/blender-git/blender/release ~/blender-git/build/bin/
For convenient access, create this symlink to run blender from the source directory: ln -s ~/blender-git/build/bin/blender ~/blender-git/blender/blender.bin
You can add any files created this way to ~/blender-git/blender/.git/info/exclude so they won't count as untracked files for git. Add your local files here, instead of in .gitignore, because .gitignore is also committed and will affect everyone else. |