Skip to content

macOS Compilation Guide

PhucNgo1711 edited this page Mar 20, 2019 · 5 revisions

Compiling CaPTk for macOS

OS Requirements

CaPTk can be built and packaged on macOS 10.12 (Sierra) equivalents and later, as required by Qt 5.12.

Library/Compiler Dependencies

Run the following command to install required libraries and dependencies and link them:

brew install caskroom/cask/mactex cmake make git-lfs doxygen llvm

Compiling

Superbuild

If this is your first time building CaPTk, the Superbuild is the best option to pull in the external dependencies (OpenCV, VTK, ITK, Qt). It is assumed that you either downloaded the latest commit over git or extracted the zip file with the CaPTk source.

  1. Navigate to the root directory of CaPTk (typically the folder where the repository was cloned to)
  2. Create a build directory and navigate to it:
mkdir bin && cd bin
  1. For cmake to be able to find LaTeX, run:
export CMAKE_PREFIX_PATH=/Library/TeX/texbin 
  1. Run cmake (twice). This is for OpenMP to be found. Cmake will automatically detect that you need a Superbuild:
cmake ../ -DCMAKE_INSTALL_PREFIX="./superbuild"
cmake ../ -DCMAKE_INSTALL_PREFIX="./superbuild"
  1. Build OpenCV, ITK, and VTK:
make

(Optionally, if your computer can handle it: $ make -j n will run with n threads. This is ideal for CaPTk.) 6. Once the Superbuild has completed building OpenCV, VTK, and ITK, run:

rm CMakeCache.txt

export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-L/usr/local/opt/llvm/include"

cmake ../
cmake ../
  1. Run make or make -j n to build CaPTk

Packaging

Once the make command has finished, run $ make package to package CaPTk using macdeployqt to generate a .app bundle

To generate a .pkg, run the following commands in the CaPTk source directory

pkgbuild --version 1.6.2.RC --identifier com.cbica.captk --install-location /Applications --component ./_CPack_Packages/OSX/DragNDrop/CaPTk_1.6.2.RC/CaPTk_1.6.2.RC.app/  ./CaPTk_1.6.2.RC.pkg
productbuild --synthesize --package CaPTk_1.6.2.RC.pkg ./distribution.xml
echo '<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
    <title>CaPTk_1.6.2.RC</title>
    <license file="Combined.txt"></license>
    <pkg-ref id="com.cbica.captk"/>
    <options customize="never" require-scripts="false"/>
    <choices-outline>
        <line choice="default">
            <line choice="com.cbica.captk"/>
        </line>
    </choices-outline>
    <choice id="default"/>
    <choice id="com.cbica.captk" visible="false">
        <pkg-ref id="com.cbica.captk"/>
    </choice>
    <pkg-ref id="com.cbica.captk" version="1.6.2.RC" onConclusion="none">CaPTk_1.6.2.RC.pkg</pkg-ref>
</installer-gui-script>' > "./distribution.xml"
productbuild --distribution ./distribution.xml --resources ./_CPack_Packages/OSX/DragNDrop/CaPTk_1.6.2.RC/CaPTk_1.6.2.RC.app/Contents/Resources/license/ --package-path . ./CaPTk_1.6.2.RC_Installer.pkg