Skip to content

Commit

Permalink
Added support of macOS on Apple Silicon (#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
willeke1234 committed Apr 11, 2024
1 parent bc713e0 commit b42b4d8
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 94 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ jobs:
build_on: linux
pkg_suffix: wx32

- run_on: macos-12
- run_on: macos-12 # x86_64
for: osx
prepare: osx
build_on: osx

- run_on: macos-14 # arm64
for: osx
prepare: osx
build_on: osx
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ cmake_install.cmake
Makefile
/_CPack_Packages/


.DS_Store
84 changes: 40 additions & 44 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,62 +156,58 @@ You can download the source code archive from GitHub

The built appimage will appear in the build/appimage-x86_64 subdirectory of current directory

## Building for OS X on OS X
1. Prequisites:
1. OS X >= 10.11
2. Xcode >= 7.3
3. homebrew
2. Extract the GO sources somewhere, eg: /home/user/gosources
3. Install the required software
- Manually
## Building for macOS on macOS

```
brew update
brew install gettext jack docbook-xsl wxmac cmake pkg-config fftw wavpack
brew link gettext --force
```
1. Prequisites:
1. A macOS version supported by Homebrew (the three latest major versions of macOS)
2. Xcode or Command Line Tools for Xcode
3. Homebrew

- Or run the prepared scripts by a sudoer user:
2. Extract the GO sources somewhere, eg: ~/documents/Projects/GrandOrgueDev/gosources using the Git method. The manual method may install the wrong version of an external submodule.

```
<GO source tree>/build-scripts/for-osx/prepare-osx.sh
```
3. Install the required software by running (the commands in)
```
<GO source tree>/build-scripts/for-osx/prepare-osx.sh
```

4. Build
- Manually
1. Create an empty build directory, eg: mkdir /home/user/gobuild
2. Run cmake:


```
cd /home/user/gobuild
cmake -G "Unix Makefiles" -DDOCBOOK_DIR=/usr/local/opt/docbook-xsl/docbook-xsl <GO source tree>
```

Hint: For debugging a build, add the ``-DCMAKE_CXX_FLAGS=-g -DCMAKE_C_FLAGS=-g`` option to cmake.

3. Run make
1. Create an empty build folder, eg: ~/documents/Projects/GrandOrgueDev/gobuild

2. Change the working directory
```
cd ~/documents/Projects/GrandOrgueDev/gobuild
```

```
3. Run cmake:
- on Apple silicon
```
cmake -G "Unix Makefiles" -DDOCBOOK_DIR=/opt/homebrew/opt/docbook-xsl/docbook-xsl <GO source tree>
```
- on Intel
```
cmake -G "Unix Makefiles" -DDOCBOOK_DIR=/usr/local/opt/docbook-xsl/docbook-xsl <GO source tree>
```
Hint: For debugging a build, add the ``-DCMAKE_CXX_FLAGS=-g -DCMAKE_C_FLAGS=-g`` option to `cmake`.

4. Run make
```
make
```


4. For making tar.gz package, run


```
make -k package VERBOSE=1
```
```

- Or run the prepared build script
- Automatically
1. Create an empty build folder, eg: ~/documents/Projects/GrandOrgueDev/gobuild

```
<GO source tree>/build-scripts/for-osx/build-on-osx.sh
```
2. Change the working directory
```
cd ~/documents/Projects/GrandOrgueDev/gobuild
```

The built package will appear in the build/osx subdirectory of current directory,
3. Run the prepared build script
```
<GO source tree>/build-scripts/for-osx/build-on-osx.sh
```
The built app will appear in the build/osx subdirectory of current directory.

## Cross-building for Windows-64 bit on Linux

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Added support of macOS on Apple silicon. GrandOrgue for macOS on Apple silicon requires macOS 14 or higher. GrandOrgue for macOS on Intel requires macOS 12.1 or higher. https://github.com/GrandOrgue/grandorgue/discussions/1153
- Added ad-hoc code signing of GrandOrgue for macOS https://github.com/GrandOrgue/grandorgue/issues/1835
- Fixed an error that occurred when trying to install the GrandOrgue RPM package https://github.com/GrandOrgue/grandorgue/issues/1859
# 3.14.0 (2024-03-29)
- Fixed crash on loading an organ without a pedal but wit a unison-off coupler https://github.com/GrandOrgue/grandorgue/issues/1846
Expand Down
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ include(${CMAKE_SOURCE_DIR}/cmake/BuildExecutable.cmake)

IF (APPLE)
set(BININSTDIR "${PROJECT_NAME}.app/Contents/MacOS")
SET(LIBINSTDIR "${PROJECT_NAME}.app/Contents/MacOS")
SET(LIBINSTDIR "${PROJECT_NAME}.app/Contents/Frameworks")
SET(RESOURCEINSTDIR "${PROJECT_NAME}.app/Contents/Resources")
SET(RPATH_PREFIX "@executable_path")
SET(RPATH_PREFIX "${PROJECT_NAME}.app/Contents/Frameworks")
ELSE()
set(BININSTDIR "bin")
IF (WIN32)
Expand Down Expand Up @@ -277,18 +277,26 @@ set(CPACK_COMPONENT_UNSPECIFIED_DEPENDS resources)
set(CPACK_COMPONENT_DEMO_DEPENDS Unspecified)

if (APPLE)
# see the following URL for information about these variables
# https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
set(BUNDLE_CFBundleShortVersionString ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_STAGE})
set(BUNDLE_CFBundleVersion ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_STAGE})
# see the following URL for information about these variables
# https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
set(BUNDLE_CFBundleShortVersionString ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_STAGE})
set(BUNDLE_CFBundleVersion ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_STAGE})

set(CPACK_PACKAGE_ICON "${RESOURCEDIR}/GrandOrgue.icns")
set(CPACK_PACKAGE_ICON "${RESOURCEDIR}/GrandOrgue.icns")

configure_file(${CMAKE_SOURCE_DIR}/src/grandorgue/resource/Info.plist.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Info.plist)
INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Info.plist DESTINATION "${PROJECT_NAME}.app/Contents/")
configure_file(${CMAKE_SOURCE_DIR}/src/grandorgue/resource/Info.plist.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Info.plist)
INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Info.plist DESTINATION "${PROJECT_NAME}.app/Contents/")

set (CPACK_SYSTEM_NAME "osx")
set (CPACK_GENERATOR DragNDrop)
add_custom_target(
macOSApplication
ALL
DEPENDS GrandOrgue GrandOrgueTool GrandOrguePerfTest resources # run after building these targets
COMMAND "${CMAKE_COMMAND}" -DAPP_DIR="${CMAKE_BINARY_DIR}" -P "${CMAKE_SOURCE_DIR}/cmake/SignMacOSApp.cmake"
)

set(CPACK_SYSTEM_NAME "macOS")
set(CPACK_GENERATOR DragNDrop)
set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_SOURCE_DIR}/cmake/SignMacOSApp.cmake")

elseif (WIN32)

Expand Down
10 changes: 6 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ This method requires that all dependencies have already been installed. Usually
2. Unpack it's contents to some directory.
3. Run ``GrandOrgue.exe`` from the `bin` subdirectory

## Installation on OSx (intel-based only)
1. Download the file grandorgue-<version>.os.osx.x86_64.dmg
2. Open it
3. Click on the keyboard icon for running
## Installation on macOS
1. Download the file grandorgue-<version>.os.macOS.x86_64.dmg (Intel) or grandorgue-<version>.os.macOS.arm64.dmg (Apple silicon)
2. Double-click the downloaded *.dmg file.
3. Drag and drop the GrandOrgue app to the Applications Folder.
4. GrandOrgue is an app from an unidentified developer. Control-click the GrandOrgue app icon in the Applications Folder, then choose Open from the shortcut menu.
5. Click Open. The GrandOrgue app is saved as an exception to your security settings, and you can open it in the future by double-clicking it just as you can any registered app.

# Deinstallation

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

GrandOrgue is a sample based pipe organ simulator.

It currently supports Linux, Windows and OS X. Porting to other OS supported by RtMidi, RtAudio and wxWidgets should be possible with some build system adjustments.
It currently supports Linux, Windows and macOS. Porting to other OS supported by RtMidi, RtAudio and wxWidgets should be possible with some build system adjustments.

## Home page and resources
GrandOrgue is hosted on Github. The repository can be found at [https://github.com/GrandOrgue/grandorgue](https://github.com/GrandOrgue/grandorgue).
Expand Down
15 changes: 10 additions & 5 deletions build-scripts/for-osx/build-on-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ set -e

source $(dirname $0)/../set-ver-prms.sh "$1" "$2"


if [[ -n "$3" ]]; then
SRC_DIR=$3
SRC_DIR=$3
else
SRC_DIR=$(dirname $0)/../..
SRC_DIR=$(dirname $0)/../..
fi

PARALLEL_PRMS="-j4"
Expand All @@ -23,10 +22,16 @@ pushd build/osx
rm -rf *
export LANG=C

OS_PRMS="-DDOCBOOK_DIR=/usr/local/opt/docbook-xsl/docbook-xsl -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1"
case `arch` in
arm64) # Apple silicon
OS_PRMS="-DDOCBOOK_DIR=/opt/homebrew/opt/docbook-xsl/docbook-xsl"
;;
i386) # Intel
OS_PRMS="-DDOCBOOK_DIR=/usr/local/opt/docbook-xsl/docbook-xsl -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1"
;;
esac
GO_PRMS="-DCMAKE_BUILD_TYPE=Release $CMAKE_VERSION_PRMS"
cmake -G "Unix Makefiles" $OS_PRMS $GO_PRMS . $SRC_DIR
make -k $PARALLEL_PRMS VERBOSE=1 package

popd

4 changes: 2 additions & 2 deletions build-scripts/for-osx/prepare-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ brew install \
brew link gettext --force

# A workaround of https://gitlab.kitware.com/cmake/cmake/-/issues/23826
for F in $(grep -l '(, weak)\?' /usr/local/Cellar/cmake/*/share/cmake/Modules/GetPrerequisites.cmake); do
for F in $(grep -l '(, weak)\?' {/usr/local,/opt/homebrew}/Cellar/cmake/*/share/cmake/Modules/GetPrerequisites.cmake); do
echo Patching $F...
# OSx sed does not support the -i option
# macOS sed does not support the -i option
sed -e 's/(, weak)\?/(, (weak|reexport))?/' $F >${F}.new
mv ${F}.new $F
done
15 changes: 15 additions & 0 deletions cmake/SignMacOSApp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Script for macOS code signing

if(NOT DEFINED APP_DIR)
set(APP_DIR "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/ALL_IN_ONE")
endif()

file(GLOB LIBSTOSIGN "${APP_DIR}/GrandOrgue.app/Contents/Frameworks/*.*")
foreach(LIBTOSIGN ${LIBSTOSIGN})
execute_process(COMMAND codesign --force --sign - "${LIBTOSIGN}")
endforeach()
execute_process(COMMAND codesign --force --sign - "${APP_DIR}/GrandOrgue.app/Contents/MacOS/GrandOrguePerfTest")
execute_process(COMMAND codesign --force --sign - "${APP_DIR}/GrandOrgue.app/Contents/MacOS/GrandOrgueTool")
execute_process(COMMAND codesign --force --sign - "${APP_DIR}/GrandOrgue.app")
message("Checking code signature...")
execute_process(COMMAND codesign --verify --deep "${APP_DIR}/GrandOrgue.app")
81 changes: 56 additions & 25 deletions src/grandorgue/resource/Info.plist.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
Expand All @@ -19,52 +19,83 @@
<key>CFBundleIdentifier</key>
<string>com.our-organ.GrandOrgue</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2009-2023 GrandOrgue contributors, Copyright 2006 Milan Digital Audio LLC</string>
<string>Copyright 2009-2024 GrandOrgue contributors, Copyright 2006 Milan Digital Audio LLC</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>organ</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>GrandOrgue.icns</string>
<key>CFBundleTypeMIMETypes</key>
<key>CFBundleTypeName</key>
<string>GrandOrgue organ definition</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>text/plain</string>
<string>com.our-organ.GrandOrgue.organ</string>
</array>
</dict>
<dict>
<key>CFBundleTypeName</key>
<string>GrandOrgue organ definition</string>
<string>GrandOrgue organ package</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>NSDocumentClass</key>
<string>GrandOrgue organ definition</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.our-organ.GrandOrgue.orgue</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<key>UTTypeConformsTo</key>
<array>
<string>orgue</string>
<string>public.data</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>GrandOrgue.icns</string>
<key>CFBundleTypeMIMETypes</key>
<key>UTTypeDescription</key>
<string>GrandOrgue organ definition</string>
<key>UTTypeIcons</key>
<dict/>
<key>UTTypeIdentifier</key>
<string>com.our-organ.GrandOrgue.organ</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>organ</string>
</array>
<key>public.mime-type</key>
<array/>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>text/plain</string>
<string>public.data</string>
</array>
<key>CFBundleTypeName</key>
<string>GrandOrgue organ package</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>NSDocumentClass</key>
<key>UTTypeDescription</key>
<string>GrandOrgue organ package</string>
<key>UTTypeIcons</key>
<dict/>
<key>UTTypeIdentifier</key>
<string>com.our-organ.GrandOrgue.orgue</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>orgue</string>
</array>
</dict>
</dict>
</array>
</dict>
Expand Down

0 comments on commit b42b4d8

Please sign in to comment.