Difference between revisions of "Compile on MacOS"

From FreeCAD Documentation
Jump to navigation Jump to search
m
 
(108 intermediate revisions by 15 users not shown)
Line 1: Line 1:
This page explains how to compile the latest FreeCAD source code on Mac OS X.
+
<languages/>
 +
<translate>
 +
 
 +
<!--T:132-->
 +
{{Docnav
 +
|[[Compile_on_Linux|Compile on Linux]]
 +
|[[Compile_on_Docker|Compile on Docker]]
 +
}}
 +
 
 +
<!--T:136-->
 +
{{VeryImportantMessage|There is an experimental FreeCAD Docker container that is being tested for FreeCAD development. Read more about it at [[Compile on Docker]]}}
 +
 
 +
</translate>
 +
{{TOCright}}
 +
<translate>
 +
 
 +
== Overview == <!--T:137-->
 +
 
 +
<!--T:72-->
 +
This page describes how to compile the FreeCAD source code on MacOS X. For other platforms, see [[Compiling|Compiling]].
 +
 
 +
<!--T:134-->
 +
These instructions have been tested on macOS Catalina with standard XCode 11.6. It is known to work on macOS BigSur Beta with XCode 12.0 beta. If you plan to use XCode Beta, please be sure to download Command Line Tools add on through a dmg package to workaround some libz dependency issues.
 +
 
 +
<!--T:119-->
 +
This page serves as a quick start, and is not intended to be comprehensive with regard to describing all the available build options.
 +
 
 +
<!--T:120-->
 +
If you just want to evaluate the latest pre-release build of FreeCAD, you can download pre-built binaries [https://github.com/FreeCAD/FreeCAD/releases from here].
 +
 
 +
== Install Prerequisites == <!--T:73-->
 +
 
 +
<!--T:139-->
 +
The following software must be installed to support the build process.
 +
 
 +
=== Homebrew Package Manager === <!--T:76-->
 +
 
 +
<!--T:140-->
 +
Homebrew is a command line based package manager for macOS. The [https://brew.sh/ Homebrew main page] provides an installation command line that you simply paste into a terminal window.
  
== Prerequisites ==
+
=== CMake === <!--T:79-->
First of all, you will need to install the following software.
 
  
=== Xcode Development Tools ===
+
<!--T:141-->
Unless you want to use the Xcode IDE for FreeCAD development, you will only need to install the Command Line Tools. To do this on 10.9 and later, open Terminal, run the following command, and then click Install in the dialog that comes up.
+
CMake is a build tool that generates a build configuration based on variables you specify. You then issue the 'make' command to actually build that configuration. The command-line version of CMake is automatically installed as part of the Homebrew installation, above. If you prefer to use a GUI version of CMake, you can download it from [https://www.cmake.org/downloadDownload here].
<pre>
 
xcode-select --install
 
</pre>
 
For other versions of OS X, you can get the package from the Apple developer [https://developer.apple.com/downloads/index.action?q=xcode downloads page] (sign in with the same Apple ID you use for other Apple services). Specifically, you will need to download Development Tools 3.2 for OS X 10.6, and Command Line Tools 4.8 for OS X 10.8.
 
  
=== Package Manager ===
+
== Install Dependencies == <!--T:82-->
You will want to use a package manager to install prerequisite software, this page gives instructions for two of the common package managers in use for OS X: [http://brew.sh/ Homebrew] and [https://www.macports.org/ MacPorts].  It's easiest to pick one package manager for your system, and not have multiple package managers installed concurrently.
 
  
==== Homebrew ====
+
<!--T:142-->
To install Homebrew, enter the following in Terminal:
+
FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal.
<pre>
 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
</pre>
 
  
==== MacPorts ====
+
</translate>
To install MacPorts, follow the instructions [https://www.macports.org/install.php from their website]
+
{{Code|code=
 +
brew tap freecad/freecad
 +
brew install eigen
 +
brew install --only-dependencies freecad
 +
}}
 +
<translate>
  
=== CMake ===
+
<!--T:121-->
FreeCAD uses [http://www.cmake.org/ CMake] to build the source.  Homebrew and MacPorts can install the command line version of CMake, or if you prefer using a GUI application, install the latest version from http://www.cmake.org/download.
+
{{Incode|brew install}} may take quite a while, so you may want go grab a beverage. :-).  
  
For the command line version of CMake, from a terminal use either Homebrew:
+
== Get the source == <!--T:85-->
<pre>
 
brew install cmake
 
</pre>
 
or MacPorts:
 
<pre>
 
sudo port install cmake
 
</pre>
 
  
== Installing the Dependencies ==
+
<!--T:143-->
All of the needed libraries can be installed using either Homebrew or MacPorts.
+
In the following instructions, the source and build folders are created side-by-side under
  
=== Homebrew Dependencies ===
+
</translate>
<pre>
+
{{Code|code=
brew tap homebrew/science
+
/Users/username/FreeCAD
brew tap sanelson/freecad
+
}}
brew install boost eigen freetype oce python qt pyside pyside-tools xerces-c
+
<translate>
brew install --without-framework --without-soqt sanelson/freecad/coin
 
brew install --HEAD pivy
 
</pre>
 
  
=== MacPorts Dependencies ===
+
<!--T:123-->
<pre>
+
but you can use whatever folders you want.
sudo port install boost eigen3 freetype oce py27-pyside-tools xercesc Coin
 
</pre>
 
  
== Getting the source ==
+
</translate>
In this guide, the source and build folders are created in '''/Users/username/FreeCAD''', but you can of course use whatever folder you want.
+
{{Code|code=
<pre>
 
 
mkdir ~/FreeCAD
 
mkdir ~/FreeCAD
 
cd ~/FreeCAD
 
cd ~/FreeCAD
</pre>
+
}}
To get the FreeCAD source code, run:
+
<translate>
<pre>
+
 
git clone git://git.code.sf.net/p/free-cad/code FreeCAD-git
+
<!--T:86-->
</pre>
+
The following command will clone the FreeCAD git repository into a directory called FreeCAD-git.
Alternatively, you can use the github mirror: https://github.com/FreeCAD/FreeCAD_sf_master.git
+
 
 +
</translate>
 +
{{Code|code=
 +
git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git
 +
}}
 +
<translate>
  
== Building FreeCAD ==
+
<!--T:89-->
First, create a new folder for the build:
+
Create the build folder.
<pre>
+
 
 +
</translate>
 +
{{Code|code=
 
mkdir ~/FreeCAD/build
 
mkdir ~/FreeCAD/build
</pre>
+
}}
Now you will need to run CMake to generate the build files.  Several options will need to be given to CMake, which can be accomplished either with the CMake GUI application, or via the command line.
+
<translate>
  
=== CMake Options ===
+
== Run CMake == <!--T:88-->
Required options will vary depending on whether Homebrew or MacPorts is used.  These instructions are valid for FreeCAD source 0.154651 (March 2015), other versions might require different options.
 
  
Note: The paths for packages like OCE and Python are version specific -- change as needed.
+
<!--T:124-->
 +
Next, we will run CMake to generate the build configuration.  Several options must be passed to CMake.  The following table describes the options and gives some background.  
  
==== Using Homebrew ====
+
=== CMake Options === <!--T:90-->
 +
 
 +
<!--T:91-->
 
{| class="wikitable" style="text-align:left"
 
{| class="wikitable" style="text-align:left"
 
|-
 
|-
 
! Name !! Value  !! Notes
 
! Name !! Value  !! Notes
|-             
 
| BUILD_ROBOT || 0 (unchecked) || As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)       
 
|-             
 
| CMAKE_BUILD_TYPE || Release ||
 
|-             
 
| FREECAD_USE_EXTERNAL_PIVY  || 1 (checked) ||
 
|-             
 
| FREETYPE_INCLUDE_DIR_freetype2 || /usr/local/include/freetype2 || You will only need to set this if you are using a CMake version older than 3.1.0
 
|-             
 
| OCE_DIR || /usr/local/Cellar/oce/0.16.1/OCE.framework/Versions/0.16/Resources ||
 
|-             
 
| PYTHON_EXECUTABLE || /usr/local/bin/python ||
 
 
|-
 
|-
| PYTHON_INCLUDE_DIR || /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 ||
+
| CMAKE_BUILD_TYPE || Release (STRING) ||  Release or Debug. Debug is generally used for developer-level testing but may also be required for user-level testing and troubleshooting.
 
|-
 
|-
| PYTHON_LIBRARY || /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib ||
+
| BUILD_QT5 || 1  (BOOL) || Required to build with Qt5. 
|-
+
|-             
|}
+
| CMAKE_PREFIX_PATH || "/usr/local/opt/qt5152;" ... (PATH) || Required to build with Qt5. See note below. You also need to add path to VTK libraries and NGLIB libraries cmake configuration file.
  
==== Using MacPorts ====
+
<!--T:125-->
{| class="wikitable" style="text-align:left"
+
|-              
 +
| FREECAD_CREATE_MAC_APP || 1 (BOOL) || Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when the 'make install' command issued.
 
|-
 
|-
! Name !! Value  !! Notes
+
| CMAKE_INSTALL_PREFIX || "./.." (PATH) || Path where you want to generate the FreeCAD.app bundle.
 
|-               
 
|-               
| BUILD_ROBOT || 0 (unchecked) || As of 12/19/2014, the robot module fails to build using newer versions of clang (OS X 10.9 and later)       
+
| FREECAD_USE_EXTERNAL_KDL || 1 (BOOL) || Required.
|-             
 
| CMAKE_BUILD_TYPE || Release ||
 
|-                     
 
| FREETYPE_INCLUDE_DIR_freetype2 || /opt/local/include/freetype2 || UNTESTED - should only need to set this if you are using a CMake version older than 3.1.0
 
|-             
 
| OCE_DIR || /opt/local/Library/Frameworks/OCE.framework/Versions/0.15/Resources || For OCE v0.15, which is dated but the latest available in MacPorts 14 March 2015
 
|-             
 
| PYSIDERCC4BINARY || /opt/local/bin/pyside-rcc-2.7 ||
 
|-             
 
| PYSIDEUIC4BINARY || /opt/local/bin/pyside-uic-2.7 ||
 
|-
 
| PYTHON_EXECUTABLE || /opt/local/bin/python2.7 ||
 
|-
 
| PYTHON_INCLUDE_DIR || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ ||
 
|-
 
| PYTHON_LIBRARY || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib ||
 
|-
 
| Shiboken_DIR || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/Shiboken-1.2.2/ ||
 
|-
 
| PySide_DIR || /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/PySide-1.2.2/ ||
 
 
|-
 
|-
 +
| BUILD_FEM_NETGEN || 1 (BOOL) || Required if choosing to build the FEM tools.
 
|}
 
|}
  
=== CMake GUI ===
+
<!--T:126-->
Open the CMake app, and fill in the source and build folder fields. In this case, it would be '''/Users/username/FreeCAD/FreeCAD-git''' for the source, and '''/Users/username/FreeCAD/build''' for the build folder.
+
Note: Command line to generate CMAKE_PREFIX_PATH: 
  
 +
</translate>
 +
<!--NOT CHANGE THE <pre> </pre> BALISE CAUSE THE PIPE OR SPACE IN MACRO CODE CUT THE MACRO-->
 +
ls -d $(brew list -1 | grep qt | tail -1 | xargs brew --cellar)/*/lib/cmake
 +
<translate>
 +
 +
=== CMake GUI === <!--T:92-->
 +
 +
<!--T:144-->
 +
Open the CMake app, and fill in the source and build folder fields. In this example, it would be '''/Users/username/FreeCAD/FreeCAD-git''' for the source, and '''/Users/username/FreeCAD/build''' for the build folder.
 +
 +
<!--T:93-->
 
Next, click the '''Configure''' button to populate the list of configuration options. This will display a dialog asking you to specify what generator to use. Leave it at the default '''Unix Makefiles.''' Configuring will fail the first time because there are some options that need to be changed. Note: You will need to check the '''Advanced''' checkbox to get all of the options.
 
Next, click the '''Configure''' button to populate the list of configuration options. This will display a dialog asking you to specify what generator to use. Leave it at the default '''Unix Makefiles.''' Configuring will fail the first time because there are some options that need to be changed. Note: You will need to check the '''Advanced''' checkbox to get all of the options.
  
 +
<!--T:135-->
 
Set options from the table above, then click '''Configure''' again and then '''Generate'''.
 
Set options from the table above, then click '''Configure''' again and then '''Generate'''.
=== CMake command line ===
+
 
Open a terminal, cd in to the build directory that was created above. Run cmake with options from the table above, following the formula -D(Name)="(Value)", and the path to your FreeCAD source directory as the final argument.
+
=== CMake command line === <!--T:94-->
<pre>
+
 
 +
<!--T:145-->
 +
Enter the following in the terminal.
 +
 
 +
</translate>
 +
{{Code|code=
 +
export PREFIX_PATH="/usr/local/opt/qt5152;\
 +
/usr/local/Cellar/nglib/v6.2.2007/Contents/Resources;\
 +
/usr/local/Cellar/vtk@8.2/8.2.0_1/lib/cmake;"
 +
}}
 +
<translate>
 +
 
 +
</translate>
 +
{{Code|code=
 
$cd ~/FreeCAD/build
 
$cd ~/FreeCAD/build
$cmake -DBUILD_ROBOT="0" ...options continue... -DPYTHON_LIBRARY="/some/path/" ../FreeCAD-git
+
$cmake \
</pre>
+
  -DCMAKE_BUILD_TYPE="Release"  \
 +
  -DBUILD_QT5=1                  \
 +
  -DWITH_PYTHON3=1              \
 +
  -DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
 +
  -DPYTHON_EXECUTABLE="/usr/local/bin/python3" \
 +
  -DFREECAD_USE_EXTERNAL_KDL=1  \
 +
  -DCMAKE_CXX_FLAGS='-std=c++14' \
 +
  -DBUILD_FEM_NETGEN=1          \
 +
  -DFREECAD_CREATE_MAC_APP=1    \
 +
  -DCMAKE_INSTALL_PREFIX="./.."  \
 +
  ../FreeCAD-git/
 +
 
 +
}}
 +
<translate>
 +
 
 +
== Run make == <!--T:127-->
 +
 
 +
<!--T:146-->
 +
Finally, from a terminal run '''make''' to compile and link FreeCAD, and generate the app bundle.
  
=== Make ===
+
</translate>
Finally, from a terminal run '''make''' to compile FreeCAD.
+
{{Code|code=
<pre>
 
 
cd ~/FreeCAD/build
 
cd ~/FreeCAD/build
make –j3
+
make -j5 install
</pre>
+
}}
 +
<translate>
 +
 
 +
<!--T:96-->
 
The -j option specifies how many make processes to run at once. One plus the number of CPU cores is usually a good number to use. However, if compiling fails for some reason, it is useful to rerun make without the -j option, so that you can see exactly where the error occurred.
 
The -j option specifies how many make processes to run at once. One plus the number of CPU cores is usually a good number to use. However, if compiling fails for some reason, it is useful to rerun make without the -j option, so that you can see exactly where the error occurred.
  
If make finishes without any errors, you can now launch FreeCAD, either from Terminal with '''./bin/FreeCAD''', or by double clicking the executable in Finder.
+
<!--T:115-->
 +
See also [[Compiling_(Speeding_up)|Compiling - Speeding up]].
 +
 
 +
<!--T:97-->
 +
If make finishes without any errors, you can now launch FreeCAD by double clicking the executable in the Finder.
 +
 
 +
== Updating from Github == <!--T:98-->
 +
 
 +
<!--T:147-->
 +
FreeCAD development happens fast; every day or so there are bug fixes or new features.  To get the latest changes, use git to update the source directory (see [[Source code management]]), then re-run the CMake and make steps above.  It is not usually necessary to start with a clean build directory in this case, and subsequent compiles will generally go much faster than the first one.
 +
 
 +
== Building with Qt4 and Python 2.7 == <!--T:100-->
  
== Updating ==
+
<!--T:148-->
FreeCAD development happens fast; everyday or so there are bug fixes or new features. To get these changes, run:
+
FreeCAD has transitioned from Qt 4 to Qt 5 as well as homebrew. Qt 4 is no longer available as an option for new build on macOS following Qt 5 transition. Python 2.7 has been deprecated within homebrew and upcoming macOS and we do not support it anymore for macOS build either.
<pre>
 
cd ~/FreeCAD/FreeCAD-git
 
git pull
 
</pre>
 
And then repeat the compile step above.
 
  
== Troubleshooting ==
+
== Troubleshooting == <!--T:130-->
  
=== Fortran ===
+
=== Segfault on Qt5 launch === <!--T:131-->
''"No CMAKE_Fortran_COMPILER could be found."'' during configuration - Older versions of FreeCAD will need a fortran compiler installed.  With Homebrew, do "brew install gcc" and try configuring again, for Macports, do "sudo port install gcc49" and give cmake the path to Fortran ie -DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.9 .  Or, preferably use a more current version of FreeCAD source!
 
  
{{docnav|CompileOnUnix|Third Party Libraries}}
+
<!--T:149-->
 +
If Qt4 was previously installed via brew, and you then build with Qt5, you may get a EXC_BAD_ACCESS (SEGSEGV) exception when launching the new Qt5 build.  The fix for this is to manually uninstall Qt4.
  
[[Category:Developer Documentation]]
+
</translate>
 +
{{Code|code=
 +
brew uninstall --ignore-dependencies --force cartr/qt4/shiboken@1.2 cartr/qt4/pyside@1.2 cartr/qt4/pyside-tools@1.2 cartr/qt4/qt-legacy-formula
 +
}}
 +
<translate>
  
{{clear}}
+
=== Fortran === <!--T:101-->
<languages/>
+
 
 +
<!--T:150-->
 +
''"No CMAKE_Fortran_COMPILER could be found."'' during configuration - Older versions of FreeCAD will need a fortran compiler installed.  With Homebrew, do "brew install gcc" and try configuring again, giving cmake the path to Fortran ie -DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.9 .  Or, preferably use a more current version of FreeCAD source!
 +
 
 +
=== FreeType === <!--T:117-->
 +
 
 +
<!--T:152-->
 +
When using CMake versions older than 3.1.0, it's necessary to set CMake variable FREETYPE_INCLUDE_DIR_freetype2 manually, eg /usr/local/include/freetype2
 +
 
 +
=== Additional Build Instructions === <!--T:153-->
 +
 
 +
<!--T:154-->
 +
FreeCAD can be built against the latest git master hosted on github, and launched from a CLI using libraries provided by the homebrew-freecad tap. For a complete list of build instructions see [https://github.com/ipatch/homebrew-us-05/tree/dev/freecad#building-freecad-for-macos-by-macos here].
 +
 
 +
<!--T:102-->
 +
{{Docnav
 +
|[[Compile_on_Linux|Compile on Linux]]
 +
|[[Compile_on_Docker|Compile on Docker]]
 +
}}
 +
 
 +
</translate>
 +
{{Userdocnavi{{#translation:}}}}
 +
[[Category:Developer_Documentation{{#translation:}}]]
 +
[[Category:Developer{{#translation:}}]]

Latest revision as of 07:31, 10 May 2022

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎hrvatski • ‎italiano • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎svenska • ‎čeština • ‎русский
There is an experimental FreeCAD Docker container that is being tested for FreeCAD development. Read more about it at Compile on Docker

Overview

This page describes how to compile the FreeCAD source code on MacOS X. For other platforms, see Compiling.

These instructions have been tested on macOS Catalina with standard XCode 11.6. It is known to work on macOS BigSur Beta with XCode 12.0 beta. If you plan to use XCode Beta, please be sure to download Command Line Tools add on through a dmg package to workaround some libz dependency issues.

This page serves as a quick start, and is not intended to be comprehensive with regard to describing all the available build options.

If you just want to evaluate the latest pre-release build of FreeCAD, you can download pre-built binaries from here.

Install Prerequisites

The following software must be installed to support the build process.

Homebrew Package Manager

Homebrew is a command line based package manager for macOS. The Homebrew main page provides an installation command line that you simply paste into a terminal window.

CMake

CMake is a build tool that generates a build configuration based on variables you specify. You then issue the 'make' command to actually build that configuration. The command-line version of CMake is automatically installed as part of the Homebrew installation, above. If you prefer to use a GUI version of CMake, you can download it from here.

Install Dependencies

FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal.

brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad

brew install may take quite a while, so you may want go grab a beverage. :-).

Get the source

In the following instructions, the source and build folders are created side-by-side under

/Users/username/FreeCAD

but you can use whatever folders you want.

mkdir ~/FreeCAD
cd ~/FreeCAD

The following command will clone the FreeCAD git repository into a directory called FreeCAD-git.

git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git

Create the build folder.

mkdir ~/FreeCAD/build

Run CMake

Next, we will run CMake to generate the build configuration. Several options must be passed to CMake. The following table describes the options and gives some background.

CMake Options

Name Value Notes
CMAKE_BUILD_TYPE Release (STRING) Release or Debug. Debug is generally used for developer-level testing but may also be required for user-level testing and troubleshooting.
BUILD_QT5 1 (BOOL) Required to build with Qt5.
CMAKE_PREFIX_PATH "/usr/local/opt/qt5152;" ... (PATH) Required to build with Qt5. See note below. You also need to add path to VTK libraries and NGLIB libraries cmake configuration file.
FREECAD_CREATE_MAC_APP 1 (BOOL) Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when the 'make install' command issued.
CMAKE_INSTALL_PREFIX "./.." (PATH) Path where you want to generate the FreeCAD.app bundle.
FREECAD_USE_EXTERNAL_KDL 1 (BOOL) Required.
BUILD_FEM_NETGEN 1 (BOOL) Required if choosing to build the FEM tools.

Note: Command line to generate CMAKE_PREFIX_PATH:

ls -d $(brew list -1 | grep qt | tail -1 | xargs brew --cellar)/*/lib/cmake

CMake GUI

Open the CMake app, and fill in the source and build folder fields. In this example, it would be /Users/username/FreeCAD/FreeCAD-git for the source, and /Users/username/FreeCAD/build for the build folder.

Next, click the Configure button to populate the list of configuration options. This will display a dialog asking you to specify what generator to use. Leave it at the default Unix Makefiles. Configuring will fail the first time because there are some options that need to be changed. Note: You will need to check the Advanced checkbox to get all of the options.

Set options from the table above, then click Configure again and then Generate.

CMake command line

Enter the following in the terminal.

export PREFIX_PATH="/usr/local/opt/qt5152;\
/usr/local/Cellar/nglib/v6.2.2007/Contents/Resources;\
/usr/local/Cellar/vtk@8.2/8.2.0_1/lib/cmake;"
$cd ~/FreeCAD/build
$cmake \
  -DCMAKE_BUILD_TYPE="Release"   \
  -DBUILD_QT5=1                  \
  -DWITH_PYTHON3=1               \
  -DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
  -DPYTHON_EXECUTABLE="/usr/local/bin/python3" \
  -DFREECAD_USE_EXTERNAL_KDL=1   \
  -DCMAKE_CXX_FLAGS='-std=c++14' \
  -DBUILD_FEM_NETGEN=1           \
  -DFREECAD_CREATE_MAC_APP=1     \
  -DCMAKE_INSTALL_PREFIX="./.."  \
  ../FreeCAD-git/

Run make

Finally, from a terminal run make to compile and link FreeCAD, and generate the app bundle.

cd ~/FreeCAD/build
make -j5 install

The -j option specifies how many make processes to run at once. One plus the number of CPU cores is usually a good number to use. However, if compiling fails for some reason, it is useful to rerun make without the -j option, so that you can see exactly where the error occurred.

See also Compiling - Speeding up.

If make finishes without any errors, you can now launch FreeCAD by double clicking the executable in the Finder.

Updating from Github

FreeCAD development happens fast; every day or so there are bug fixes or new features. To get the latest changes, use git to update the source directory (see Source code management), then re-run the CMake and make steps above. It is not usually necessary to start with a clean build directory in this case, and subsequent compiles will generally go much faster than the first one.

Building with Qt4 and Python 2.7

FreeCAD has transitioned from Qt 4 to Qt 5 as well as homebrew. Qt 4 is no longer available as an option for new build on macOS following Qt 5 transition. Python 2.7 has been deprecated within homebrew and upcoming macOS and we do not support it anymore for macOS build either.

Troubleshooting

Segfault on Qt5 launch

If Qt4 was previously installed via brew, and you then build with Qt5, you may get a EXC_BAD_ACCESS (SEGSEGV) exception when launching the new Qt5 build. The fix for this is to manually uninstall Qt4.

brew uninstall --ignore-dependencies --force cartr/qt4/shiboken@1.2 cartr/qt4/pyside@1.2 cartr/qt4/pyside-tools@1.2 cartr/qt4/qt-legacy-formula

Fortran

"No CMAKE_Fortran_COMPILER could be found." during configuration - Older versions of FreeCAD will need a fortran compiler installed. With Homebrew, do "brew install gcc" and try configuring again, giving cmake the path to Fortran ie -DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.9 . Or, preferably use a more current version of FreeCAD source!

FreeType

When using CMake versions older than 3.1.0, it's necessary to set CMake variable FREETYPE_INCLUDE_DIR_freetype2 manually, eg /usr/local/include/freetype2

Additional Build Instructions

FreeCAD can be built against the latest git master hosted on github, and launched from a CLI using libraries provided by the homebrew-freecad tap. For a complete list of build instructions see here.