-
Notifications
You must be signed in to change notification settings - Fork 65
macOS Compilation Guide
CaPTk can be built and packaged on macOS 10.12 (Sierra) equivalents and later, as required by Qt 5.12.
Run the following command to initialize sub-modules through git
:
git submodule update --init --recursive
Run the following command to install required libraries and dependencies and link them:
brew install caskroom/cask/mactex cmake make doxygen libomp openmpi glfw wget
If this is your first time building CaPTk, the Superbuild is the best option to pull in the external dependencies (OpenCV, VTK, ITK, DCMTK, Qt). It is assumed that you either downloaded the latest commit over git or extracted the zip file with the CaPTk source.
- Navigate to the root directory of CaPTk (typically the folder where the repository was cloned to)
- Create a build directory and navigate to it:
mkdir -p bin && cd bin
- Download precompiled binaries and Qt:
wget https://github.com/CBICA/CaPTk/raw/master/binaries/precompiledApps/macos.zip -O binaries_macos.zip
wget https://github.com/CBICA/CaPTk/raw/master/binaries/qt_5.12.1/macos.zip -O qt.zip
- Run cmake. Cmake will automatically detect that you need a Superbuild:
export CMAKE_PREFIX_PATH=/Library/TeX/texbin
export CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE
cmake ../ -DCMAKE_INSTALL_PREFIX="./install"
- Build OpenCV, ITK, VTK, and DCMTK:
make
(Optionally, if your computer can handle it: $ make -j n
will run with n
threads. This is ideal for CaPTk.)
- Once the Superbuild has completed building OpenCV, ITK, VTK, and DCMTK, run:
cmake ../
rm CMakeCache.txt
export CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE
export CMAKE_PREFIX_PATH="/Library/TeX/texbin"
export CMAKE_PREFIX_PATH=$(Build.SourcesDirectory)/bin/ITK-build:$(Build.SourcesDirectory)/bin/DCMTK-build:$(Build.SourcesDirectory)/bin/qt/5.12.1/lib/cmake/Qt5:$CMAKE_PREFIX_PATH
cmake -DITK_DIR=./ITK-build -DDCMTK_DIR=./DCMTK-build ../
- Run
make
ormake -j n
to build CaPTk
Once the make command has finished, run $ make package
to package CaPTk using macdeployqt
to generate a .app
bundle and a .dmg
installer.
The .dmg
is one option for the CaPTk installer, but it poses a risk of the user running the a non-packaged version of CaPTk during the installation process.
The second option is to create a .pkg
using pkgbuild
and productbuild
tools , which are available in macOS by default.
To generate a .pkg
, run the following commands in the build directory:
version=$(grep -i -e "project_version:*" CMakeCache.txt | cut -c24-)
pkgname="_Installer"
pkgname="$version$pkgname"
pkgbuild --version $version --identifier com.cbica.captk --install-location /Applications --component $(Build.SourcesDirectory)/bin/_CPack_Packages/OSX/DragNDrop/CaPTk_$version/ALL_IN_ONE/CaPTk_$version.app/ ./CaPTk_$version.pkg
productbuild --synthesize --package CaPTk_$version.pkg ./distribution.xml
xml='<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<title>CaPTk_'"$version"'</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="$version" onConclusion="none">CaPTk_'"$version"'.pkg</pkg-ref>
</installer-gui-script>'
echo $xml > "./distribution.xml"
productbuild --distribution ./distribution.xml --resources $(Build.SourcesDirectory)/bin/_CPack_Packages/OSX/DragNDrop/CaPTk_$version/ALL_IN_ONE/CaPTk_$version.app/Contents/Resources/license/ --package-path . ./CaPTk_$pkgname.pkg
CaPTk, 2022 | About CaPTk | Please report any issues here