Compile on MacOS: Difference between revisions
m (fixed docnav) |
No edit summary |
||
Line 1: | Line 1: | ||
<translate> |
<translate> |
||
<!--T:72--> |
<!--T:72--> |
||
This page explains how to compile the latest FreeCAD source |
This page explains how to compile the '''latest''' FreeCAD source on macOS X. In this context, '''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 try using the latest pre-release build of FreeCAD, you can download pre-built binaries from https://github.com/FreeCAD/FreeCAD/releases . |
|||
== Prerequisites == <!--T:73--> |
== Prerequisites == <!--T:73--> |
||
The following software must be installed to support the build process. |
|||
=== Package Manager === <!--T:76--> |
=== Package Manager === <!--T:76--> |
||
Download and install [https://brew.sh/ Homebrew] |
|||
=== CMake === <!--T:79--> |
=== CMake === <!--T:79--> |
||
Line 13: | Line 15: | ||
<!--T:106--> |
<!--T:106--> |
||
The command-line version of CMake will be automatically installed by Homebrew in the prerequisites step |
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--> |
||
All of the needed libraries can be installed using Homebrew. We maintain a "tap" including a formula for FreeCAD, |
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--> |
<!--T:118--> |
||
Line 27: | Line 29: | ||
brew tap homebrew/science |
brew tap homebrew/science |
||
brew tap freecad/freecad |
brew tap freecad/freecad |
||
brew install --only-dependencies freecad |
brew install --only-dependencies freecad --with-packaging-utils |
||
brew install --only-dependencies freecad |
brew install --only-dependencies freecad --with-packaging-utils |
||
</pre> |
</pre> |
||
Note: if you need to build with Qt4, add "--with |
|||
<translate> |
<translate> |
||
== Getting the source == <!--T:85--> |
== Getting the source == <!--T:85--> |
||
In this guide, the source and build folders are created in '''/Users/username/FreeCAD''', but you can of course use whatever folder you want. |
In this guide, the source and build folders are created in '''/Users/username/FreeCAD''', but you can, of course, use whatever folder you want. |
||
</translate> |
</translate> |
||
<pre> |
<pre> |
||
Line 65: | Line 68: | ||
! 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_PREFIX_PATH || "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" (string) || When building with Qt5, must specify this location, otherwise Cmake will not be able to locate the Qt5 libraries, and the build will fail. For building with Qt4, use "/usr/local/Cellar/qt\@5.6/5.6.2/lib/cmake". |
|||
|- |
|||
| FREECAD_CREATE_MAC_APP || 1 (checked) || Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when 'make install' command issued. |
|||
⚫ | |||
| CMAKE_INSTALL_PREFIX || "./.." (string) || Path where you want to generate the FreeCAD.app bundle. |
|||
|- |
|- |
||
| FREECAD_USE_EXTERNAL_KDL || 1 (checked) || |
| FREECAD_USE_EXTERNAL_KDL || 1 (checked) || |
||
⚫ | |||
| CMAKE_BUILD_TYPE || Debug || Can be Debug or Release. Debug is generally used for development |
|||
|- |
|- |
||
| BUILD_FEM_NETGEN || 1 (checked) || |
| BUILD_FEM_NETGEN || 1 (checked) || |
||
⚫ | |||
| FREECAD_CREATE_MAC_APP || 1 (checked) || If you want to make a FreeCAD.app , this CMake option will cause "make install" to create a FreeCAD.app bundle in CMAKE_INSTALL_PREFIX . |
|||
|} |
|} |
||
Revision as of 00:57, 17 July 2017
This page explains how to compile the latest FreeCAD source on macOS X. In this context, 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 try using the latest pre-release build of FreeCAD, you can download pre-built binaries from https://github.com/FreeCAD/FreeCAD/releases .
Prerequisites
The following software must be installed to support the build process.
Package Manager
Download and install Homebrew
CMake
FreeCAD uses CMake to build the source. CMake comes in two versions, command-line and GUI. Use whichever you prefer.
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
All of the needed libraries can be installed using Homebrew. We maintain a "tap" including a formula for FreeCAD, which installs the dependencies.
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.
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
brew tap homebrew/science brew tap freecad/freecad brew install --only-dependencies freecad --with-packaging-utils brew install --only-dependencies freecad --with-packaging-utils
Note: if you need to build with Qt4, add "--with
Getting the source
In this guide, the source and build folders are created in /Users/username/FreeCAD, but you can, of course, use whatever folder you want.
mkdir ~/FreeCAD cd ~/FreeCAD
To get the FreeCAD source code, this command will create a "clone" of the FreeCAD git repository in to a new directory called FreeCAD-git:
git clone https://github.com/FreeCAD/FreeCAD FreeCAD-git
Building FreeCAD
Create a new folder for the build:
mkdir ~/FreeCAD/build
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.
CMake Options
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. |
BUILD_QT5 | 1 (checked) | Required to build with Qt5. Set to 0 (unchecked) to build with Qt4. |
CMAKE_PREFIX_PATH | "/usr/local/Cellar/qt@5.6/5.6.2/lib/cmake" (string) | When building with Qt5, must specify this location, otherwise Cmake will not be able to locate the Qt5 libraries, and the build will fail. For building with Qt4, use "/usr/local/Cellar/qt\@5.6/5.6.2/lib/cmake". |
FREECAD_CREATE_MAC_APP | 1 (checked) | Create a FreeCAD.app bundle at the location specified in CMAKE_INSTALL_PREFIX, when 'make install' command issued. |
CMAKE_INSTALL_PREFIX | "./.." (string) | Path where you want to generate the FreeCAD.app bundle. |
FREECAD_USE_EXTERNAL_KDL | 1 (checked) | |
BUILD_FEM_NETGEN | 1 (checked) |
CMake GUI
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.
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
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.
$cd ~/FreeCAD/build $cmake -DFREECAD_USE_EXTERNAL_KDL="1" ...options continue... -DFREECAD_CREATE_MAC_APP ="1" ../FreeCAD-git
Make
Finally, from a terminal run make to compile FreeCAD.
cd ~/FreeCAD/build make –j3
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, either from Terminal with ./bin/FreeCAD, or by double clicking the executable in 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.
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