Skip to content

Commit 672951b

Browse files
Finish renaming app to SIUE Fat Segmentation Tool
Rename MacDeployScript to MacDeployScript.sh Ignore MacDeployScript.sh from Git. Add sample MacDeployScript with indicators like this <INSERT-HERE> to change for custom path.
1 parent 565a14f commit 672951b

2 files changed

Lines changed: 124 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ CMakeLists.txt.user
4343
error.log
4444

4545
# Installation Scripts, ignore these since they contain path dependent scripts that will be different from computer to computer
46-
MacDeployScript
47-
WindowsInstaller.iss
46+
MacDeployScript.sh
47+
WindowsInstaller.iss

MacDeployScript.sh.sample

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
3+
# Location of libraries to import into app bundle
4+
LIB_DIR=/usr/local/lib
5+
6+
# Application name
7+
APP_NAME="SIUE Fat Segmentation Tool"
8+
9+
# Version
10+
VERSION=v1.0.2.0
11+
12+
# Release type (Debug|Release)
13+
RELEASE=Debug
14+
15+
# Name for DMG
16+
DMG_NAME=$APP_NAME-$VERSION-$RELEASE-OSX_x64
17+
18+
# Location of the application bundle to include libraries
19+
APP_DIR=<PATH-TO-APP-REMOVE-DEBUG/RELEASE-PREFIX>-$RELEASE/$APP_NAME.app
20+
21+
# Location of DMG directory that contains contents of what the DMG will have in it
22+
DMG_DIR=$APP_DIR/../dmg_folder
23+
24+
# Location of the actual application binary inside app bundle
25+
APP_BIN=Contents/MacOS/$APP_NAME
26+
27+
# Location of macdeployqt file
28+
MACDEPLOYQT=<PATH-TO-MACDEPLOYQT>/macdeployqt
29+
30+
# List of third-party libraries that will be imported to the App bundle
31+
# Do NOT include Qt libraries or system libraries because Qt libraries are handled by macdeployqt and system libraries do not need to be imported
32+
#
33+
# Run otool -L /path/to/app/Contents/MacOS/app to get a list of dependencies for program. Exclude any Qt file or files beginning with /System/* or /usr/lib/*
34+
# The remaining libraries beginning with @rpath or /usr/local/lib will likely need to be imported
35+
#
36+
# For each library, run otool -L LIB_NAME on that library to get a list of dependencies for THAT library. Note which libraries require which dependencies because that
37+
# needs to be changed. Include all of the libraries dependencies in the LIBS list too. (Only if it is new and not already included in list).
38+
# This is recursive. So for each new library, you MUST run otool on it to get dependencies for THAT library then.
39+
LIBS=(
40+
"libnifticdf.2.dylib"
41+
"libniftiio.2.dylib"
42+
"libopencv_core.3.2.dylib"
43+
"libopencv_imgproc.3.2.dylib"
44+
"libopencv_highgui.3.2.dylib"
45+
"libopencv_video.3.2.dylib"
46+
"libznz.2.dylib"
47+
"libopencv_videoio.3.2.dylib"
48+
"libopencv_imgcodecs.3.2.dylib"
49+
)
50+
51+
# When replacing the old path name to the new one, use these directory prefixes. Should NOT need to be changed. This changes any directories beginning with @rpath or $LIB_DIR
52+
OLD_PATH_DIRS=($LIB_DIR "@rpath")
53+
54+
# Contains a multidimensional array of dependencies between libraries. First value indicates the dependency and the second value is the library that contains the dependency.
55+
#
56+
# As specified above in LIBS documentation, run otool -L LIB_NAME for each library and note the dependencies. If any third-party dependencies are present, include them below
57+
# so they are changed upon running of script.
58+
DEPS=(
59+
"libznz.2.dylib" "libniftiio.2.dylib"
60+
61+
"libopencv_imgproc.3.2.dylib" "libopencv_imgproc.3.2.dylib"
62+
63+
"libopencv_videoio.3.2.dylib" "libopencv_highgui.3.2.dylib"
64+
"libopencv_imgcodecs.3.2.dylib" "libopencv_highgui.3.2.dylib"
65+
"libopencv_imgproc.3.2.dylib" "libopencv_highgui.3.2.dylib"
66+
"libopencv_core.3.2.dylib" "libopencv_highgui.3.2.dylib"
67+
68+
"libopencv_imgproc.3.2.dylib" "libopencv_video.3.2.dylib"
69+
"libopencv_core.3.2.dylib" "libopencv_video.3.2.dylib"
70+
71+
"libopencv_imgcodecs.3.2.dylib" "libopencv_videoio.3.2.dylib"
72+
"libopencv_imgproc.3.2.dylib" "libopencv_videoio.3.2.dylib"
73+
"libopencv_core.3.2.dylib" "libopencv_videoio.3.2.dylib"
74+
75+
"libopencv_imgproc.3.2.dylib" "libopencv_imgcodecs.3.2.dylib"
76+
"libopencv_core.3.2.dylib" "libopencv_imgcodecs.3.2.dylib"
77+
)
78+
79+
# Run macdeployqt to fix Qt library dependencies
80+
$MACDEPLOYQT "$APP_DIR"
81+
82+
# Loop through each library and copy the library to Frameworks dir in app bundle, add ID using install_name and change the library name in main application to use relative path
83+
for i in "${LIBS[@]}"
84+
do
85+
cp $LIB_DIR/$i "$APP_DIR/Contents/Frameworks/$i"
86+
87+
install_name_tool -id @executable_path/../Frameworks/$i "$APP_DIR/Contents/Frameworks/$i"
88+
89+
for j in "${OLD_PATH_DIRS[@]}"
90+
do
91+
install_name_tool -change $j/$i @executable_path/../Frameworks/$i "$APP_DIR/$APP_BIN"
92+
done
93+
done
94+
95+
# Loop through each dependency between libraries and change the corresponding name to new relative path in library
96+
ARR_SIZE=${#DEPS[@]}
97+
for i in "${OLD_PATH_DIRS[@]}"
98+
do
99+
for ((j=0; j<$ARR_SIZE; j = j + 2))
100+
do
101+
install_name_tool -change $i/${DEPS[$j]} @executable_path/../Frameworks/${DEPS[$j]} "$APP_DIR/Contents/Frameworks/${DEPS[$j+1]}"
102+
done
103+
done
104+
105+
# Create dmg directory
106+
mkdir "$DMG_DIR"
107+
108+
# Remove EVERYTHING from dmg directory.
109+
rm -rf "$DMG_DIR/*"
110+
111+
# Copy app bundle to dmg folder
112+
cp -R "$APP_DIR" "$DMG_DIR/"
113+
114+
# Create symlink of Applications in folder so user can drag application to folder
115+
ln -s /Applications "$DMG_DIR/Applications"
116+
117+
# Create DMG file with contents being the contents of $DMG_DIR
118+
hdiutil create -volname "$APP_NAME" -srcfolder "$DMG_DIR" -ov -format UDZO "$APP_DIR/../$DMG_NAME.dmg"
119+
120+
# Output otool result to see if all dependencies were met
121+
otool -L "$APP_DIR/$APP_BIN"
122+
otool -L "$APP_DIR/Contents/Frameworks/lib"*

0 commit comments

Comments
 (0)