How to compile Blender from source on OSX?
The Blender documentation page https://wiki.blender.org/wiki/Building_Blender/Mac contains instructions on how you can compile Blender for a Mac machine. Note that the instructions below might not be as accurate anymore since lots of things might have changed.



But they don't quite work. When you get to the line "make", make fails, because the CLANG compiler that comes with XCode can't process "openMP" library.

Instead you need to use a specially built version of CLANG that DOES support openMP. (openMP pertains to threading on multiprocessor architectures, if you're curious. It is bad of Apple that their CLANG compilers behind with this.)

As you can see from that page, you pull the blender source code from git, and a bunch of already compiled binaries from SVN.

piBookAir:darwin-9.x.universal pi$ pwd
/Users/pi/Dev/Blender/blender-build/lib/darwin-9.x.universal

piBookAir:darwin-9.x.universal pi$ ls
README      freetype    opencollada osl     sdl
boost       gettext     opencolorio png     sndfile
clang-omp   jpeg        openexr     python      tiff
ffmpeg      llvm        openimageio release
fftw3       openal      openmp      samplerate


As you can see from the listing, it contains this special clang-omp

So you could probably make sure that that is getting found in your path before the existing CLANG, and it will work.

I haven't tried, because Jens showed me how to get it working using SCons.

SCons and CMake are two different ways of automating the process of setting up the build. if you're familiar with AutoTools, you can think of CMake as being AutoTools brought up to date in a way that works nicely on Windows systems also. And SCons does the same thing but using Python.

Now the big difference is that CMake is an actual program you have to download and install on your system, whereas SCons is just a Python script.

To me that makes SCons a clear winner, and it is indeed painless to do it this way.

So, create /pathto/blender-build/blender/user-config.py as follows:

CC = '../lib/darwin-9.x.universal/clang-omp/bin/clang'
CXX = '../lib/darwin-9.x.universal/clang-omp/bin/clang++'


And then run:

sysctl hw.logicalcpu 


to find out how many CPUs new machine has (my MacBook Air has 4, a modern MacBook Pro has 12)

Now: 

cd /pathto/blender-build/blender
python scons/scons.py -j4


And grab a cup of tea (or 4 if you forgot the -j4 parameter)

Now you should have:

/pathto/blender-build/install/darwin/blender.app