From 8390237cc458b6ba9deeff435dbd18d9ce2d205a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 2 Aug 2020 04:49:26 +0200 Subject: [PATCH] Fix Sparkle integration for macOS --- .travis.yml | 4 +++- CMakeLists.txt | 9 +++++++-- dist/macos/macdeploy.py | 11 +++++++---- src/core/mac_startup.mm | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c48bbcd9..c8065778d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ before_install: brew install libcdio libmtp libimobiledevice libplist; brew install create-dmg; brew cask install sparkle; + sudo ln -s /usr/local/Caskroom/sparkle/$(ls /usr/local/Caskroom/sparkle | head -n1)/Sparkle.framework /Library/Frameworks/Sparkle.framework; + sudo ln -s /usr/local/Caskroom/sparkle/$(ls /usr/local/Caskroom/sparkle | head -n1)/Sparkle.framework.dSYM /Library/Frameworks/Sparkle.framework.dSYM; export Qt5_DIR=/usr/local/opt/qt5/lib/cmake; export Qt5LinguistTools_DIR=/usr/local/opt/qt5/lib/cmake/Qt5LinguistTools; export PATH="/usr/local/opt/gettext/bin:$PATH"; @@ -34,7 +36,7 @@ before_install: fi before_script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build cmake -Hstrawberry -Bbuild ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON -DSPARKLE= ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON ; fi script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build make -C build -j8 ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then diff --git a/CMakeLists.txt b/CMakeLists.txt index f05dfa718..12bf7abec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,11 @@ if(${CMAKE_BUILD_TYPE} MATCHES "Debug") set(DEBUG ON) endif() +if(APPLE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks") +endif() + find_program(CCACHE_EXECUTABLE NAMES ccache) if (CCACHE_EXECUTABLE) message(STATUS "ccache found: will be used for compilation and linkage") @@ -253,10 +258,10 @@ set(SINGLEAPPLICATION_LIBRARIES singleapplication) set(SINGLECOREAPPLICATION_LIBRARIES singlecoreapplication) if(APPLE) - find_library(SPARKLE Sparkle PATHS /usr/local/Caskroom/sparkle/1.22.0 NAMES Sparkle Sparkle.framework) + find_library(SPARKLE Sparkle) endif(APPLE) -if((NOT SPARKLE) AND (APPLE OR WIN32)) +if(NOT SPARKLE AND (APPLE OR WIN32)) if(WITH_QT6) pkg_check_modules(QTSPARKLE qtsparkle-qt6) else() diff --git a/dist/macos/macdeploy.py b/dist/macos/macdeploy.py index d9c31a0e9..12f02688e 100755 --- a/dist/macos/macdeploy.py +++ b/dist/macos/macdeploy.py @@ -31,7 +31,8 @@ LIBRARY_SEARCH_PATH = ['/usr/local/lib'] FRAMEWORK_SEARCH_PATH = [ '/Library/Frameworks', - os.path.join(os.environ['HOME'], 'Library/Frameworks') + os.path.join(os.environ['HOME'], 'Library/Frameworks'), + '/Library/Frameworks/Sparkle.framework/Versions' ] QT_PLUGINS = [ @@ -190,7 +191,7 @@ def GetBrokenLibraries(binary): elif re.match(r'^\s*/usr/lib/', line): #print "unix style system lib" continue # unix style system library - elif re.match(r'^\s*@executable_path', line) or re.match(r'^\s*@loader_path', line): + elif re.match(r'^\s*@executable_path', line) or re.match(r'^\s*@rpath', line) or re.match(r'^\s*@loader_path', line): # Potentially already fixed library path = line.split('/')[3:] if path: @@ -421,12 +422,14 @@ def FixLibraryInstallPath(library_path, library): def FixFrameworkInstallPath(library_path, library): parts = library_path.split(os.sep) + full_path = "" for i, part in enumerate(parts): if re.match(r'\w+\.framework', part): full_path = os.path.join(*parts[i:]) break - new_path = '@executable_path/../Frameworks/%s' % full_path - FixInstallPath(library_path, library, new_path) + if full_path: + new_path = '@executable_path/../Frameworks/%s' % full_path + FixInstallPath(library_path, library, new_path) def FindQtPlugin(name): diff --git a/src/core/mac_startup.mm b/src/core/mac_startup.mm index bff804432..b88df8170 100644 --- a/src/core/mac_startup.mm +++ b/src/core/mac_startup.mm @@ -53,7 +53,7 @@ #include "globalshortcuts/globalshortcutbackend-macos.h" #ifdef HAVE_SPARKLE -# import +# import #endif #include