Setting CMake options?

Not so sure these instructions are clear. The first way mentioned to edit CMake options is this Editing CMakeCache.txt in a text editor. This clearly does nothing. I set WITH_GMP:BOOL=OFF to WITH_GMP:BOOL=ON and then did make lite and it’s as if I did nothing.

You first have to run make lite from your blender source dir. This generates a directory ../build_<platform>_lite. You can then edit the CmakeCache.txt folder in that directory and re-run cmake (also in that directory). Or you can run cmake-gui or the like from that directory. Don’t forget to re-run cmake . from that same directory to make cmake pick up your changes to CMakeCache.txt and put them in the new generated makefile.

And look out, if you re-run make lite from the blender dir, it will overwrite your CMakeCache.txt file.

It’s a bit of a hassle indeed. You can also edit CMakeLists.txt in the blender dir for more permanent changes. But that’s a different syntax (hurray :frowning: ) .

I ended up running rebuild in the build folder and changes seem to take. Even stays when doing make lite after.

make full/lite/release are meant too bootstrap a build type, it loads a predefined set of cmake options every time you call it overwriting any settings you may have done, as you can see from the cmake output

k:\BlenderGit\blender>make lite 2019 builddir mybuild nobuild
** Visual Studio 2019 Developer Command Prompt v16.7.2
** Copyright (c) 2020 Microsoft Corporation
[vcvarsall.bat] Environment initialized for: 'x64'
Building blender with VS2019 for x64 in k:\BlenderGit\blender\..\mybuild
loading initial cache file k:\BlenderGit\blender\\build_files\cmake\config\blender_lite.cmake
-- The C compiler identification is MSVC 19.27.29111.0

make lite/full/release is setup to have a novice get up and building quickly, and if all you want is build “todays blender” it will work great for you.

As soon as you go, “i want to play around with options/do some actual development”, you’re not really the target audience for this helper anymore and it will as you have noticed just get in your way. It’s best that you run it once to get the build setup for you and once you have your build folder, you should just run make (or ninja if you chose a ninja based build) in your build folder on linux/mac. On windows where the build system is are not make based it leaves a convenience rebuild.cmd in the build folder for you, that will re-run cmake so it catches up on any changes in your CMakeCache.txt and kicks off the compilation process for you.

I do not recommend doing that, for a couple of reasons.

  1. Many defaults are only set at the initial cmake run when it creates your CMakeCache.txt for the first time, changing the value of these defaults later on in the main CMakeLists.txt and re-running cmake will not update your existing CMakeCache.txt .

  2. when you run make lite/full/release if will overwrite any settings done in the main CMakeLists.txt ie if you set WITH_GMP to off in the CMakeLists.txt file. and run make full even with a brand new build folder to sidestep 1, it will load the settings from build_files/cmake/config/blender_full.cmake resulting to WITH_GMP still being on.

  3. It’s a local build preference you’d like to set, you should not be editing upstream code to reach that goal. CMake offers supported ways though CMakeCache.txt to set these options, use them. Editing code in the source folder to reach that goal is just an accidental “whoopsy” commit waiting to happen.


I agree with you. And I’m probably not trained enough in CMake’s workings to give good advice here.

Only thing is, I’ve done quite a lot of bisecting the last few days, which does always happen from the source dir. And the only way I could get my builds to complete reliably when jumping around between different branches or distant versions was by completely wiping the build dir for every bisect step. This made hacking CMakeLists.txt to me the easier way (with my rudimentary CMake knowledge).