More 10.14 fixes also make the version check in cmakelists actually work
This commit is contained in:
parent
e0cb998591
commit
bc4a156a4d
|
@ -136,7 +136,7 @@ if (APPLE)
|
|||
set_source_files_properties("${CMAKE_SOURCE_DIR}/melon.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
|
||||
# Qt 6 requires macOS 10.15 if building on 10.15 or greater
|
||||
if(CMAKE_SYSTEM_VERSION VERSION_GREATER "10.14")
|
||||
if(CMAKE_SYSTEM_VERSION VERSION_GREATER 18.5.0)
|
||||
if (USE_QT6)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
|
||||
endif()
|
||||
|
|
|
@ -47,9 +47,9 @@ def expand_load_path(lib, path)
|
|||
get_rpaths(lib).each do |rpath|
|
||||
file = File.join(rpath, file_name)
|
||||
return file, :rpath if File.exist? file
|
||||
if rpath.match? /^@executable_path(.*)/
|
||||
if rpath.match(/^@executable_path(.*)/) != nil
|
||||
relative = rpath.sub(/^@executable_path/, "")
|
||||
return "#{$bundle}/Contents/MacOS#{relative}", :executable_path
|
||||
return "#{$bundle}/Contents/MacOS#{relative}/#{file_name}", :executable_path
|
||||
end
|
||||
end
|
||||
file = $fallback_rpaths
|
||||
|
@ -69,9 +69,6 @@ def expand_load_path(lib, path)
|
|||
return File.absolute_path(path), :absolute
|
||||
end
|
||||
|
||||
puts lib
|
||||
puts path
|
||||
exit
|
||||
return nil
|
||||
end
|
||||
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
build_dmg=0
|
||||
app=melonDS.app
|
||||
|
||||
if [[ "$1" == "--dmg" ]]; then
|
||||
build_dmg=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ ! -d "$1" ]]; then
|
||||
echo "Usage: $0 [--dmg] <build-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$1"
|
||||
|
||||
# macOS does not have the -f flag for readlink
|
||||
abspath() {
|
||||
perl -MCwd -le 'print Cwd::abs_path shift' "$1"
|
||||
}
|
||||
|
||||
cmake_qtdir=$(grep -E "Qt._DIR" CMakeCache.txt)
|
||||
qtdir="$(abspath "$(echo "$cmake_qtdir/../../.." | cut -d= -f2)")"
|
||||
|
||||
plugindir="$app/Contents/PlugIns"
|
||||
if [[ ! -d "$plugindir" ]]; then
|
||||
qt_plugins="$qtdir/plugins"
|
||||
if [[ ! -d "$qt_plugins" ]]; then
|
||||
qt_plugins="$qtdir/share/qt/plugins"
|
||||
fi
|
||||
if [[ ! -d "$qt_plugins" ]]; then
|
||||
qt_major="$(echo "$cmake_qtdir" | sed -E 's/Qt(.)_DIR.*/\1/')"
|
||||
qt_plugins="$qtdir/libexec/qt$qt_major/plugins"
|
||||
fi
|
||||
|
||||
mkdir -p "$plugindir/styles" "$plugindir/platforms"
|
||||
cp "$qt_plugins/styles/libqmacstyle.dylib" "$plugindir/styles/"
|
||||
cp "$qt_plugins/platforms/libqcocoa.dylib" "$plugindir/platforms/"
|
||||
fi
|
||||
|
||||
fixup_libs() {
|
||||
local libs=($(otool -L "$1" | grep -vE "/System|/usr/lib|:$|@rpath|@loader_path|@executable_path" | sed -E 's/'$'\t''(.*) \(.*$/\1/'))
|
||||
|
||||
for lib in "${libs[@]}"; do
|
||||
if [[ "$lib" != *"/"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Dereference symlinks to get the actual .dylib as binaries' load
|
||||
# commands can contain paths to symlinked libraries.
|
||||
local abslib="$(abspath "$lib")"
|
||||
|
||||
if [[ "$abslib" == *".framework/"* ]]; then
|
||||
local fwpath="$(echo "$abslib" | sed -E 's@(.*\.framework)/.*@\1/@')"
|
||||
local fwlib="$(echo "$abslib" | sed -E 's/.*\.framework//')"
|
||||
local fwname="$(basename "$fwpath")"
|
||||
local install_path="$app/Contents/Frameworks/$fwname"
|
||||
|
||||
install_name_tool -change "$lib" "@rpath/$fwname/$fwlib" "$1"
|
||||
|
||||
if [[ ! -d "$install_path" ]]; then
|
||||
cp -a "$fwpath" "$install_path"
|
||||
find -H "$install_path" "(" -type d -or -type l ")" -name Headers -exec rm -rf "{}" +
|
||||
chown -R $UID "$install_path"
|
||||
chmod -R u+w "$install_path"
|
||||
strip -SNTx "$install_path/$fwlib"
|
||||
fixup_libs "$install_path/$fwlib"
|
||||
fi
|
||||
else
|
||||
local base="$(basename "$abslib")"
|
||||
local install_path="$app/Contents/Frameworks/$base"
|
||||
|
||||
install_name_tool -change "$lib" "@rpath/$base" "$1"
|
||||
|
||||
if [[ ! -f "$install_path" ]]; then
|
||||
install -m644 "$abslib" "$install_path"
|
||||
strip -SNTx "$install_path"
|
||||
fixup_libs "$install_path"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [[ ! -d "$app/Contents/Frameworks" ]]; then
|
||||
mkdir -p "$app/Contents/Frameworks"
|
||||
install_name_tool -add_rpath "@executable_path/../Frameworks" "$app/Contents/MacOS/melonDS"
|
||||
fi
|
||||
|
||||
fixup_libs "$app/Contents/MacOS/melonDS"
|
||||
find "$app/Contents/PlugIns" -name '*.dylib' | while read lib; do
|
||||
fixup_libs "$lib"
|
||||
done
|
||||
|
||||
bad_rpaths=($(otool -l "$app/Contents/MacOS/melonDS" | grep -E "^ *path (/usr/local|/opt)" | sed -E 's/^ *path (.*) \(.*/\1/' || true))
|
||||
|
||||
for path in "${bad_rpaths[@]}"; do
|
||||
install_name_tool -delete_rpath "$path" "$app/Contents/MacOS/melonDS"
|
||||
done
|
||||
|
||||
codesign -s - --deep -f "$app"
|
||||
|
||||
if [[ $build_dmg == 1 ]]; then
|
||||
mkdir dmg
|
||||
cp -a "$app" dmg/
|
||||
ln -s /Applications dmg/Applications
|
||||
hdiutil create -fs HFS+ -volname melonDS -srcfolder dmg -ov -format UDBZ melonDS.dmg
|
||||
rm -r dmg
|
||||
fi
|
Loading…
Reference in New Issue