Skip to content

Commit 5ab3472

Browse files
committed
Enable macOS install & packaging
Requires a few hacks regarding the installer, to prevent the "Install Rosetta" dialog from being shown and also make the package non-relocatable, which wreaks havoc when installing on development machines,like overwriting the bundle in the build dir.
1 parent 8329b1a commit 5ab3472

File tree

7 files changed

+51
-11
lines changed

7 files changed

+51
-11
lines changed

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
1515

1616
option(ENABLE_FLAT_PACKAGE "Creates a \"flat\" install layout with the executable, configuration file(s) and preset/texture dirs directly in the install prefix." OFF)
1717
option(ENABLE_INSTALL_BDEPS "Installs all shared libraries projectMSDL requires to run. On some platforms, CMake 3.31 or higher is required for this to work!" OFF)
18+
19+
set(PROJECTMSDL_PROPERTIES_FILENAME "projectMSDL.properties")
20+
1821
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ENABLE_FLAT_PACKAGE)
1922
include(GNUInstallDirs)
2023

@@ -24,7 +27,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ENABLE_FLAT_PACKAGE)
2427
set(PROJECTMSDL_PRESETS_DIR "${PROJECTMSDL_DATA_DIR}/presets" CACHE STRING "Directory to install optional preset files, relative to the install prefix.")
2528
set(PROJECTMSDL_TEXTURES_DIR "${PROJECTMSDL_DATA_DIR}/textures" CACHE STRING "Directory to install optional texture files, relative to the install prefix.")
2629

27-
2830
# Additional options for desktop integration
2931
option(ENABLE_DESKTOP_ICON "Install a .desktop file and icons" ON)
3032
set(PROJECTMSDL_DESKTOP_DIR "${CMAKE_INSTALL_DATAROOTDIR}/applications" CACHE STRING "Directory to install the .desktop file in, relative to the install prefix.")
@@ -47,7 +49,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT ENABLE_FLAT_PACKAGE)
4749

4850
set(DEFAULT_CONFIG_PATH "\${application.dir}/../Resources" CACHE STRING "Optional path to look for the configuration file in addition to PROJECTMSDL_BIN_DIR.")
4951
set(DEFAULT_PRESETS_PATH "\${application.dir}/../Resources/Presets" CACHE STRING "Default presets path in the configuration file.")
50-
set(DEFAULT_TEXTURES_PATH "\${application.dir}/../Resources/Presets" CACHE STRING "Default textures path in the configuration file.")
52+
set(DEFAULT_TEXTURES_PATH "\${application.dir}/../Resources/Textures" CACHE STRING "Default textures path in the configuration file.")
53+
54+
set(PROJECTMSDL_PROPERTIES_FILENAME "projectM.properties")
55+
56+
set(CMAKE_INSTALL_RPATH "@loader_path/../PlugIns")
5157
else()
5258
set(DEFAULT_PACKAGING_CONFIG "packaging-windows.cmake")
5359

@@ -61,6 +67,7 @@ else()
6167
set(DEFAULT_CONFIG_PATH "" CACHE STRING "Optional path to look for the configuration file in addition to PROJECTMSDL_BIN_DIR.")
6268
set(DEFAULT_PRESETS_PATH "\${application.dir}/presets" CACHE STRING "Default presets path in the configuration file.")
6369
set(DEFAULT_TEXTURES_PATH "\${application.dir}/textures" CACHE STRING "Default textures path in the configuration file.")
70+
6471
endif()
6572

6673
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")

cmake/CPack.distribution.dist.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<installer-gui-script minSpecVersion="1.0">
3+
<title>@CPACK_PACKAGE_NAME@</title>
4+
<welcome file="@CPACK_RESOURCE_FILE_WELCOME_NOPATH@"/>
5+
<readme file="@CPACK_RESOURCE_FILE_README_NOPATH@"/>
6+
<license file="@CPACK_RESOURCE_FILE_LICENSE_NOPATH@"/>
7+
<options allow-external-scripts="no" customize="allow" rootVolumeOnly="false" hostArchitectures="@CPACK_OSX_ARCHITECTURES@"></options>
8+
<domains enable_anywhere="true" enable_currentUserHome="false" enable_localSystem="true"/>
9+
@CPACK_PACKAGEMAKER_CHOICES@
10+
</installer-gui-script>

install.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ install(TARGETS projectMSDL
77

88
install(FILES ${PROJECTM_CONFIGURATION_FILE}
99
DESTINATION ${PROJECTMSDL_DATA_DIR}
10+
RENAME ${PROJECTMSDL_PROPERTIES_FILENAME}
1011
COMPONENT projectMSDL
1112
)
1213

1314
if(ENABLE_INSTALL_BDEPS)
1415
install(RUNTIME_DEPENDENCY_SET projectMSDLDepends
16+
COMPONENT projectMSDL
1517

1618
# Important: Due to CMake bug #24606 this needs to stay at the top of the argument list!
1719
# Exclude OS libraries on Linux/macOS
@@ -20,6 +22,7 @@ if(ENABLE_INSTALL_BDEPS)
2022
"^/usr/lib(32|64)?/+"
2123
"^/Library/+"
2224

25+
LIBRARY DESTINATION ${PROJECTMSDL_LIB_DIR}
2326
RUNTIME DESTINATION ${PROJECTMSDL_LIB_DIR}
2427
FRAMEWORK DESTINATION ${PROJECTMSDL_DATA_DIR}
2528
)

packaging-macos.cmake

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ set(CPACK_STRIP_FILES TRUE)
1212
### Productbuild configuration
1313
set(CPACK_PKGBUILD_IDENTITY_NAME "${CODESIGN_IDENTITY_INSTALLER}")
1414
set(CPACK_PRODUCTBUILD_IDENTITY_NAME "${CODESIGN_IDENTITY_INSTALLER}")
15+
set(CPACK_PRODUCTBUILD_IDENTIFIER "org.projectm-visualizer.projectmsdl")
1516

16-
set(CPACK_PRODUCTBUILD_DOMAINS TRUE)
17-
set(CPACK_PRODUCTBUILD_DOMAINS_ANYWHERE TRUE)
18-
set(CPACK_PRODUCTBUILD_DOMAINS_USER TRUE)
19-
set(CPACK_PRODUCTBUILD_DOMAINS_ROOT TRUE)
20-
21-
set(CPACK_PACKAGE_INSTALL_DIRECTORY /)
22-
set(CPACK_PACKAGING_INSTALL_PREFIX /)
17+
string(REPLACE ";" "," INSTALL_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
18+
file(WRITE "${CMAKE_BINARY_DIR}/CPackAdditionalConfig.cmake" "set(CPACK_OSX_ARCHITECTURES \"${INSTALL_ARCHITECTURES}\")")
19+
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackAdditionalConfig.cmake")
2320

2421
# Installer texts
2522
set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/src/resources/macos-welcome.txt")
@@ -31,3 +28,7 @@ set(CPACK_GENERATOR productbuild)
3128
set(CPACK_SOURCE_GENERATOR TGZ)
3229

3330
include(CPack)
31+
32+
cpack_add_component(projectMSDL
33+
PLIST "${CMAKE_SOURCE_DIR}/src/resources/projectMSDL-component.plist"
34+
)

src/ProjectMSDLApplication.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void ProjectMSDLApplication::initialize(Poco::Util::Application& self)
7272
{
7373
Poco::Path configFilePath(configPath);
7474
configFilePath.makeDirectory().setFileName(configFileName);
75+
poco_information_f1(logger(), "Trying to load configuration from %s.", configFilePath.toString());
7576
if (Poco::File(configFilePath).exists())
7677
{
7778
loadConfiguration(configFilePath.toString(), PRIO_DEFAULT);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<array>
5+
<dict>
6+
<key>BundleHasStrictIdentifier</key>
7+
<true/>
8+
<key>BundleIsRelocatable</key>
9+
<false/>
10+
<key>BundleIsVersionChecked</key>
11+
<true/>
12+
<key>BundleOverwriteAction</key>
13+
<string>upgrade</string>
14+
<key>RootRelativeBundlePath</key>
15+
<string>Applications/projectM.app</string>
16+
</dict>
17+
</array>
18+
</plist>

src/resources/projectMSDL.properties.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ window.fullscreen.width = 0
2525
window.fullscreen.height = 0
2626

2727
# Window size if not in fullscreen
28-
window.width = 1024
29-
window.height = 768
28+
window.width = 1920
29+
window.height = 1080
3030

3131
# Override system default window position
3232
window.overridePosition = false

0 commit comments

Comments
 (0)