Compile on MacOS

Since Mac OS X is BSD (UNIX) based, compiling FreeCAD on a Mac isn't much different from CompileOnUnix, however there are a number of Mac-specific details critical to getting everything working properly. These instructions have been tested on Lion (10.7), but should work on Intel Macs running (Snow) Leopard as well.

Getting the source
Before you can compile FreeCAD, you need the source code. There are 3 ways to get it:

Git
The quickest and best way to get the code is to clone the read-only git repository (you need the git package installed):

This will place a copy of the latest version of the FreeCAD source code in a new directory called "freecad". The first time you try connecting to the free-cad.git.sourceforge.net host, you will receive a message asking to authenticate the sourceforge SSH key, which is normally safe to accept (you can check their SSH keys on the sourceforge website if you are not sure)

Github
There is an always up to date FreeCAD repository on Gihub: github.com/FreeCAD/FreeCAD_sf_master

Source package
Alternatively you can download a source package, but they could be already quite old so it's always better to get the latest sources. Depending on your distribution, there are several ways to obtain a source package:

Official FreeCAD source packages (distribution-independent): https://sourceforge.net/projects/free-cad/files/FreeCAD%20Source/

Debian: http://packages.debian.org/source/sid/freecad

Ubuntu: http://packages.ubuntu.com/source/precise/freecad

Install Dependencies
On Mac OS X 10.7, the following dependencies are NOT bundled with the operating and thus must be installed before building FreeCAD:
 * sip
 * fortran
 * xerces-c
 * boost
 * eigen
 * ftgl
 * coin3d
 * OpenCASCADE
 * Qt
 * pyqt
 * soqt

Option 1: Homebrew
Note: this section is still a work in progress! See the help forum post for the latest.
 * https://forum.freecadweb.org/viewtopic.php?f=4&t=2064&p=15405

Download and install the package manager Homebrew:
 * http://mxcl.github.com/homebrew/

Then compile and install most of FreeCAD's dependencies: Go on to CompileOnMac.

Option 2: MacPorts/Fink
Note: this section is in need of updates.

Install MacPorts (if you don't already have it). MacPorts is a system that allows you to download, compile, and install many common open-source applications with a single command. Similar applications from the UNIX/Linux world are PKGSRC and APT. To install, just download the disk image from the MacPorts site and follow the directions:
 * http://www.macports.org/install.php

Whether or not you just installed MacPorts, you'll probably want to make sure it's up to date. Run:

Now that MacPorts is installed and up to date, you can start installing some of FreeCAD's required packages:
 * xercesc
 * boost
 * py-sip
 * ftlg
 * f2c
 * eigen3
 * py-pyqt4
 * Coin

The following command will compile/install the above libraries. If MacPorts produces errors, you may want to try installing them one at a time.

Note that for python packages like py-sip and py-pyqt4, there are multiple packages, one for each MacPorts version of Python.

Note that boost is a large package, and py-pyqt4 depends on qt4-mac, which is a large package. You may want to run port -v install so that you have more of an idea what's going on during these long builds.

Qt4 is also available for Mac as a binary installer from the Qt web site. I'm not sure how nicely this approach plays with FreeCAD compiling.

It is also possible to choose the version of the gcc compiler to use, some recent versions might sometimes cause problems:

Install Fortran Compiler

You also need a FORTRAN compiler. Apple's fork of gcc on OSX does not come with FORTRAN.

An installer for GFortran can be found here, and will do the trick: http://gcc.gnu.org/wiki/GFortranBinaries#MacOS

If you are using fink, another method is to use the following commands (attempted by Shaneyfelt 2100.Nov.14)

This installs another gcc compiler collection with the name gcc-4 to avoid a name conflict with the apple one.

MacPorts gcc4x packages also include FORTRAN compilers, so this should also work:

Another possible MacPorts package is g95. This seems to be a valid FORTRAN90 compiler and will pass FreeCAD's cmake configuration tests, but the actual build seems to ask for gcc-specific options, so probably easier to stick to gcc4x.

Install Eigen3

Download and unzip the latest eigen3 library here: http://eigen.tuxfamily.org/index.php?title=Main_Page

These are needed for solver functionality. Once unzipped, the folder named 'Eigen' can be dropped into

/usr/local/include/eigen3/

Build OpenCASCADE
Currently, the easiest way to build OpenCASCADE on OS X is from the community edition (oce). Download the source or check out the Git repository from:
 * https://github.com/tpaviot/oce

Then, in terminal:

You may need cmake:

Download and 'install' the FreeCAD.app template
The following archive contains an application bundle template for FreeCAD. This is not strictly necessary, but it makes working with FreeCAD more convenient than the default installation configuration. The recommended install location for the bundle is the /Applications folder, but you should be able to put it anywhere you want -- just remember that the bundle can't be moved after FreeCAD is complied and installed without further modifications. Running make install using the configuration in the next step will install into this bundle.
 * http://dl.getdropbox.com/u/103808/FreeCAD/FreeCAD_bundle_template_20091128.tar.gz

Compile
Configure, compile, and install FreeCAD using the following commands from within the root FreeCAD folder. If you put your FreeCAD.app bundle somewhere other than /Applications (or aren't using the bundle), change the 'PREFIX' argument accordingly.

If you installed dependencies using Option 1 (Homebrew):

Note: this config line has not been verified and may contain errors!

Or if you installed dependencies using Option 2 (MacPorts/Fink):

Then:

Depending on your machine's processing power, the make step can take quite a while.

Run
If everything went OK, double-clicking the .app bundle should start FreeCAD. If you have any issues, post the details on the help forum.

PyQt4
Some users reported facing a "No Module named PyQt4" message on FreeCAD startup. This is a workaround to correct it:

Pivy
Some FreeCAD components won't work without Pivy. See here for partial build instructions.