Compile on MacOS: Difference between revisions
No edit summary |
(Update compile instructions for macOS.) |
||
Line 1: | Line 1: | ||
<translate> |
<translate> |
||
<!--T:72--> |
<!--T:72--> |
||
This page |
This page describes how to compile the latest FreeCAD source on macOS X. ''Latest'' means the most recent commit to the master branch of the FreeCAD github repository. |
||
This page serves as a quick start, and is not intended to be comprehensive with regard to describing all the available build options. |
|||
⚫ | |||
⚫ | |||
== Prerequisites == <!--T:73--> |
== Prerequisites == <!--T:73--> |
||
The following software must be installed |
The following software must be installed. |
||
=== Package Manager === <!--T:76--> |
=== Homebrew Package Manager === <!--T:76--> |
||
Homebrew is a command line based package manager for macOS. The [https://brew.sh/ Homebrew main page] provides a command line that you simply paste into a terminal window. |
|||
Download and install [https://brew.sh/ Homebrew] |
|||
=== CMake === <!--T:79--> |
=== CMake === <!--T:79--> |
||
CMake is 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]. |
|||
FreeCAD uses [http://www.cmake.org/ CMake] to build the source. CMake comes in two versions, command-line and GUI. Use whichever you prefer. |
|||
<!--T:106--> |
|||
The command-line version of CMake will be automatically installed by Homebrew in the prerequisites step. The GUI version can be downloaded directly from https://www.cmake.org/download . |
|||
== Installing the Dependencies == <!--T:82--> |
== Installing the Dependencies == <!--T:82--> |
||
FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal. |
|||
All of the needed libraries can be installed using Homebrew. We maintain a "tap" including a formula for FreeCAD, which installs the dependencies. |
|||
<!--T:118--> |
|||
We are currently transitioning FreeCAD from Qt 4 to Qt 5; the Homebrew formula will default to installing Qt5.6 unless --with-qt4 is specified along with --only-dependencies. |
|||
<!--T:116--> |
<!--T:116--> |
||
. |
|||
''Note that there is currently a bug where the dependencies aren't all installed on the first run of brew install... - the duplicate line below is intentional'' |
|||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
brew tap homebrew/science |
brew tap homebrew/science |
||
brew tap freecad/freecad |
brew tap freecad/freecad |
||
brew install eigen |
|||
brew install --only-dependencies freecad --with-packaging-utils |
brew install --only-dependencies freecad --with-packaging-utils |
||
brew install --only-dependencies freecad --with-packaging-utils |
brew install --only-dependencies freecad --with-packaging-utils |
||
</pre> |
</pre> |
||
Note: if you need to build with Qt4, add "--with |
|||
<translate> |
<translate> |
||
Notes: |
|||
# The duplicate 'brew install' command for freecad dependencies is intentional. There is currently a bug where some of the dependencies are not installed on the first run. |
|||
# 'brew install' may take quite a while, so you may want go grab a beverage. :-) |
|||
== Getting the source == <!--T:85--> |
== Getting the source == <!--T:85--> |
||
In |
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. |
||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
Line 44: | Line 44: | ||
<translate> |
<translate> |
||
<!--T:86--> |
<!--T:86--> |
||
The following command will clone the FreeCAD git repository into a directory called FreeCAD-git. |
|||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
Line 52: | Line 52: | ||
== Building FreeCAD == <!--T:88--> |
== Building FreeCAD == <!--T:88--> |
||
Create |
Create the build folder and move into it. |
||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
mkdir ~/FreeCAD/build |
mkdir ~/FreeCAD/build |
||
cd ~/FreeCAD/build |
|||
</pre> |
</pre> |
||
<translate> |
<translate> |
||
<!--T:89--> |
<!--T:89--> |
||
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 === <!--T:90--> |
=== CMake Options === <!--T:90--> |
||
Line 68: | Line 69: | ||
! Name !! Value !! Notes |
! Name !! Value !! Notes |
||
|- |
|- |
||
| CMAKE_BUILD_TYPE || Release || Release or Debug. Debug is generally used for developer-level testing but may be required for user-level testing and troubleshooting. |
| 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 ( |
| BUILD_QT5 || 1 (BOOL) || Required to build with Qt5. |
||
|- |
|- |
||
| CMAKE_PREFIX_PATH || "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" ( |
| CMAKE_PREFIX_PATH || "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" (PATH) || Required to build with Qt5. |
||
|- |
|- |
||
| FREECAD_CREATE_MAC_APP || 1 ( |
| 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 || "./.." ( |
| CMAKE_INSTALL_PREFIX || "./.." (PATH) || Path where you want to generate the FreeCAD.app bundle. |
||
|- |
|- |
||
| FREECAD_USE_EXTERNAL_KDL || 1 ( |
| FREECAD_USE_EXTERNAL_KDL || 1 (BOOL) || Required. |
||
|- |
|- |
||
| BUILD_FEM_NETGEN || 1 ( |
| BUILD_FEM_NETGEN || 1 (BOOL) || Required. |
||
|} |
|} |
||
=== CMake GUI === <!--T:92--> |
=== CMake GUI === <!--T:92--> |
||
Open the CMake app, and fill in the source and build folder fields. In this |
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--> |
<!--T:93--> |
||
Line 91: | Line 92: | ||
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 === <!--T:94--> |
=== CMake command line === <!--T:94--> |
||
Enter the following in the terminal. |
|||
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. |
|||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
$cd ~/FreeCAD/build |
$cd ~/FreeCAD/build |
||
$cmake \ |
|||
$cmake -DFREECAD_USE_EXTERNAL_KDL="1" ...options continue... -DFREECAD_CREATE_MAC_APP ="1" ../FreeCAD-git |
|||
-DCMAKE_BUILD_TYPE="Release" \ |
|||
-DBUILD_QT5=1 \ |
|||
-DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" \ |
|||
-DFREECAD_USE_EXTERNAL_KDL=1 \ |
|||
-DBUILD_FEM_NETGEN=1 \ |
|||
-DFREECAD_CREATE_MAC_APP=1 \ |
|||
-DCMAKE_INSTALL_PREFIX="./.." \ |
|||
../FreeCAD-git/ |
|||
</pre> |
</pre> |
||
<translate> |
<translate> |
||
=== Make === <!--T:95--> |
=== Make === <!--T:95--> |
||
Finally, from a terminal run '''make''' to compile FreeCAD. |
Finally, from a terminal run '''make''' to compile FreeCAD. |
||
Line 104: | Line 113: | ||
<pre> |
<pre> |
||
cd ~/FreeCAD/build |
cd ~/FreeCAD/build |
||
make |
make –j5 install |
||
</pre> |
</pre> |
||
<translate> |
<translate> |
||
Line 114: | Line 123: | ||
<!--T:97--> |
<!--T:97--> |
||
If make finishes without any errors, you can now launch FreeCAD, |
If make finishes without any errors, you can now launch FreeCAD, by double clicking the executable in the Finder. |
||
== Updating == <!--T:98--> |
== Updating == <!--T:98--> |
||
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. |
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. |
||
== Notes on building with Qt4 == <!--T:100--> |
|||
FreeCAD has transitioned from Qt 4 to Qt 5. If you need to build with Qt4, the following additional steps are required. |
|||
# Append '--with-qt4' to the 'brew install' command. |
|||
# Do not specify BUILD_QT5 CMake option. |
|||
# Do not specify CMAKE_PREFIX_PATH CMake option |
|||
== Troubleshooting == <!--T:100--> |
== Troubleshooting == <!--T:100--> |
Revision as of 02:30, 17 July 2017
This page describes how to compile the latest FreeCAD source on macOS X. Latest means the most recent commit to the master branch of the FreeCAD github repository.
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.
Prerequisites
The following software must be installed.
Homebrew Package Manager
Homebrew is a command line based package manager for macOS. The Homebrew main page provides a command line that you simply paste into a terminal window.
CMake
CMake is 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.
Installing the Dependencies
FreeCAD maintains a Homebrew 'tap' which installs the required formulas and dependencies. Issue the following brew commands in your terminal.
.
brew tap homebrew/science brew tap freecad/freecad brew install eigen brew install --only-dependencies freecad --with-packaging-utils brew install --only-dependencies freecad --with-packaging-utils
Notes:
- The duplicate 'brew install' command for freecad dependencies is intentional. There is currently a bug where some of the dependencies are not installed on the first run.
- 'brew install' may take quite a while, so you may want go grab a beverage. :-)
Getting 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
Building FreeCAD
Create the build folder and move into it.
mkdir ~/FreeCAD/build cd ~/FreeCAD/build
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/Cellar/qt@5.6/5.6.2/lib/cmake" (PATH) | Required to build with Qt5. |
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. |
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.
$cd ~/FreeCAD/build $cmake \ -DCMAKE_BUILD_TYPE="Release" \ -DBUILD_QT5=1 \ -DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" \ -DFREECAD_USE_EXTERNAL_KDL=1 \ -DBUILD_FEM_NETGEN=1 \ -DFREECAD_CREATE_MAC_APP=1 \ -DCMAKE_INSTALL_PREFIX="./.." \ ../FreeCAD-git/
Make
Finally, from a terminal run make to compile FreeCAD.
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
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.
Notes on building with Qt4
FreeCAD has transitioned from Qt 4 to Qt 5. If you need to build with Qt4, the following additional steps are required.
- Append '--with-qt4' to the 'brew install' command.
- Do not specify BUILD_QT5 CMake option.
- Do not specify CMAKE_PREFIX_PATH CMake option
Troubleshooting
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!
OpenGL
See OpenGL on MacOS for OpenGL issues when Qt 4.8 and earlier are used on MacOS.
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