My main programming project over the last couple days involves “building” FreeCAD on Apple OS X. Building is the process that takes a program’s source code and turns it into an executable program. The details often involve some changes depending on which operating system the program is meant to be built and used on.
Apparently not many people have been building FreeCAD on OS X recently, so getting a current version of FreeCAD was a bit difficult for OS X users – especially for non-programmers. There were some scattered instructions on the wiki, which I had used successfully in the past, but it seemed like most FreeCAD compilation was done on Linux or Windows.
I use a Mac for my personal work, and my “gut feel” (backed up by some research) says there are lots of other potential FreeCAD Mac users. So, I wanted to work on improving FreeCAD on my Mac, and might as well make it easier for other people to do the same!
What does that involve? A mix of work, but for FreeCAD the glue that holds the build process together is CMake. Essentially, CMake lets developers write a program, which in turn helps to build another program. A snippet from a CMake script:
To get FreeCAD built on my system, I initially had to figure out what to tell CMake, so it could find the relevant libraries and such on my computer. Fortunately, another FreeCAD developer had recently done some work along the same lines, so this wasn’t too difficult. Result at this stage for my computer looks something like:
cmake -DBUILD_ROBOT="0" -DFREECAD_USE_EXTERNAL_PIVY="1" -DCMAKE_BUILD_TYPE="Release" -DOCE_DIR="/opt/local/Library/Frameworks/OCE.framework/Versions/0.15/Resources" -DPYTHON_LIBRARY="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib" -DPYTHON_EXECUTABLE="/opt/local/bin/python2.7" -DShiboken_DIR="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/Shiboken-1.2.2/" -DPySide_DIR="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/cmake/PySide-1.2.2/" -DPYSIDERCC4BINARY="/opt/local/bin/pyside-rcc-2.7" -DPYSIDEUIC4BINARY="/opt/local/bin/pyside-uic-2.7" -DPYTHON_INCLUDE_DIR="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/" -DFREECAD_CREATE_MAC_APP="1" ../freecad-code
Then, once that was done, the next step was to make the CMake script smarter so that other people wouldn’t need to bother with that whole mess. The OS X platform poses some additional challenges here, in that there are a few competing package managers in common use. This means the location of some relevant libraries will be different, even among computers with the same operating system.
So, I’ve spent some time over the last couple days mucking around with CMake scripts to make the build process on Mac a bit more automated using two of the most common package managers. Once this is all done, the cmake command line above will hopefully be reduced for MacPorts and Homebrew users to something more like:
cmake -DBUILD_ROBOT="0" ../freecad-code
Cost: Approximately 5 cups tea, counting this post, so far, and feeling close to done.