Skip to content

Commit

Permalink
Draft: macOS: Add M1/arm64 support
Browse files Browse the repository at this point in the history
Closes #1884
  • Loading branch information
hluk committed Feb 5, 2024
1 parent c369875 commit 41d64dc
Show file tree
Hide file tree
Showing 23 changed files with 288 additions and 421 deletions.
97 changes: 0 additions & 97 deletions .github/workflows/build-linux.yml

This file was deleted.

12 changes: 7 additions & 5 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
strategy:
matrix:
include:
- os: macos-12
buildname: macOS 10.15
- os: macos-14
buildname: macOS 12 M1
create_bundle: true
bundle_suffix: '-macos-12-m1'
cmake_preset: macOS-12-m1

steps:
- name: Checkout source code
Expand Down Expand Up @@ -42,8 +44,8 @@ jobs:
- name: Build with CMake
uses: lukka/run-cmake@v10
with:
configurePreset: macOS
buildPreset: macOS
configurePreset: '${{ matrix.cmake_preset }}'
buildPreset: '${{ matrix.cmake_preset }}'

- name: Create gnupg directory for tests
run: mkdir -p ~/.gnupg && chmod go-rwx ~/.gnupg
Expand All @@ -57,5 +59,5 @@ jobs:
if: matrix.create_bundle
uses: actions/upload-artifact@v4
with:
name: CopyQ.dmg
name: 'CopyQ${{ matrix.bundle_suffix }}.dmg'
path: '${{runner.workspace}}/build/CopyQ.dmg'
60 changes: 0 additions & 60 deletions .gitlab-ci.yml

This file was deleted.

28 changes: 25 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
{
"name": "macOS",
"name": "macOS-10",
"generator": "Ninja",
"binaryDir": "${sourceParentDir}/build",
"installDir": "${sourceParentDir}/build",
Expand All @@ -26,6 +26,22 @@
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_FLAGS": "-Wno-deprecated-declarations"
}
},
{
"name": "macOS-12-m1",
"generator": "Ninja",
"binaryDir": "${sourceParentDir}/build",
"installDir": "${sourceParentDir}/build",
"cacheVariables": {
"WITH_QT6": "TRUE",
"WITH_TESTS": "TRUE",
"CMAKE_PREFIX_PATH": "/usr/local/opt/qt/lib/cmake",
"CMAKE_OSX_DEPLOYMENT_TARGET": "12",
"CMAKE_OSX_ARCHITECTURES": "arm64",
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_FLAGS": "-Wno-deprecated-declarations"
}
}
],
"buildPresets": [
Expand All @@ -36,8 +52,14 @@
"targets": "install"
},
{
"name": "macOS",
"configurePreset": "macOS",
"name": "macOS-10",
"configurePreset": "macOS-10",
"configuration": "Release",
"targets": "install"
},
{
"name": "macOS-12-m1",
"configurePreset": "macOS-12-m1",
"configuration": "Release",
"targets": "install"
}
Expand Down
57 changes: 0 additions & 57 deletions appveyor.yml

This file was deleted.

12 changes: 2 additions & 10 deletions docs/build-source-code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,15 @@ On OS X, required Qt 5 libraries and utilities can be easily installed with `Hom
# brew untap --force copyq/kde
# and re-run the above "brew tap" command

brew install qt5 copyq/kde/kf5-knotifications
brew install qt6 copyq/kde/kf6-knotifications copyq/kde/kf6-kstatusnotifieritem

Build with the following commands:

::

cmake -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)" .
cmake --build .
cmake --install .
macdeployqt CopyQ.app -dmg -verbose=2 -always-overwrite \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitemfakevim.so \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitemimage.so \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitemnotes.so \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitempinned.so \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitemsync.so \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitemtags.so \
-executable=CopyQ.app/Contents/PlugIns/copyq/libitemtext.so
cpack

This will produce a self-contained application bundle ``CopyQ.app``
which can then be copied or moved into ``/Applications``.
Expand Down
55 changes: 26 additions & 29 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ endif()
if (NOT APPLE)
add_executable(${COPYQ_EXECUTABLE_NAME} ${copyq_COMPILE})
else()
# On Macs we must ensure Carbon and Cocoa are linked
FIND_LIBRARY(CARBON_LIBRARY "Carbon")
FIND_LIBRARY(COCOA_LIBRARY "Cocoa")
MARK_AS_ADVANCED (CARBON_LIBRARY
COCOA_LIBRARY)
FIND_LIBRARY(CARBON_LIBRARY Carbon REQUIRED)
FIND_LIBRARY(COCOA_LIBRARY Cocoa REQUIRED)
MARK_AS_ADVANCED(CARBON_LIBRARY COCOA_LIBRARY)
list(APPEND copyq_LIBRARIES "${CARBON_LIBRARY}" "${COCOA_LIBRARY}")

set(COPYQ_VERSION_REGEX "^([0-9]+)\.([0-9]+)\.(.*)$")
Expand Down Expand Up @@ -158,6 +156,7 @@ if (NOT APPLE)
else()
set_source_files_properties(${copyq_QM} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/translations")

set_target_properties(${COPYQ_EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(${COPYQ_EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/../shared/Info.plist")

set(plugin_dest_dir "${COPYQ_EXECUTABLE_NAME}.app/Contents/PlugIns")
Expand Down Expand Up @@ -194,28 +193,26 @@ else()
COMPONENT Runtime
)

# FIXME: Disable cpack for now due to unresolvable libraries:
# https://github.com/Homebrew/homebrew-core/issues/140930
# set(FIXUP_BUNDLE_APPS "\${CMAKE_INSTALL_PREFIX}/${COPYQ_EXECUTABLE_NAME}.app")
#
# get_property(_copyq_installed_plugins GLOBAL PROPERTY COPYQ_INSTALLED_PLUGINS)
#
# # Directories to look for dependencies
# set(FIXUP_BUNDLE_DEP_DIRS "${CMAKE_BINARY_DIR};${QT_LIBRARY_DIRS};${QT_PLUGINS_DIR}/iconengines;${QT_PLUGINS_DIR}/imageformats;${QT_PLUGINS_DIR}/platforms;${QT_PLUGINS_DIR}/tls;${${copyq_qt}Widgets_DIR}/../..")
#
# message(STATUS "Fixup app: ${FIXUP_BUNDLE_APPS}")
# message(STATUS "Fixup app plugins: ${_copyq_installed_plugins}")
# message(STATUS "Fixup qt plugins: ${FIXUP_BUNDLE_QT_PLUGINS}")
# message(STATUS "Fixup dirs: ${FIXUP_BUNDLE_DEP_DIRS}")
# install(CODE "
# include(BundleUtilities)
# set(BU_CHMOD_BUNDLE_ITEMS ON)
# fixup_bundle(\"${FIXUP_BUNDLE_APPS}\" \"${FIXUP_BUNDLE_QT_PLUGINS};${_copyq_installed_plugins}\" \"${FIXUP_BUNDLE_DEP_DIRS}\")
# verify_app(\"${FIXUP_BUNDLE_APPS}\")
# "
# COMPONENT Runtime
# )
#
# set(CPACK_GENERATOR "DragNDrop")
# include(CPack)
set(FIXUP_BUNDLE_APPS "\${CMAKE_INSTALL_PREFIX}/${COPYQ_EXECUTABLE_NAME}.app")

get_property(_copyq_installed_plugins GLOBAL PROPERTY COPYQ_INSTALLED_PLUGINS)

# Directories to look for dependencies
set(FIXUP_BUNDLE_DEP_DIRS "${CMAKE_BINARY_DIR};${QT_LIBRARY_DIRS};${QT_PLUGINS_DIR}/iconengines;${QT_PLUGINS_DIR}/imageformats;${QT_PLUGINS_DIR}/platforms;${QT_PLUGINS_DIR}/tls;${${copyq_qt}Widgets_DIR}/../..")

message(STATUS "Fixup app: ${FIXUP_BUNDLE_APPS}")
message(STATUS "Fixup app plugins: ${_copyq_installed_plugins}")
message(STATUS "Fixup qt plugins: ${FIXUP_BUNDLE_QT_PLUGINS}")
message(STATUS "Fixup dirs: ${FIXUP_BUNDLE_DEP_DIRS}")
install(CODE "
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle(\"${FIXUP_BUNDLE_APPS}\" \"${FIXUP_BUNDLE_QT_PLUGINS};${_copyq_installed_plugins}\" \"${FIXUP_BUNDLE_DEP_DIRS}\")
verify_app(\"${FIXUP_BUNDLE_APPS}\")
"
COMPONENT Runtime
)

set(CPACK_GENERATOR "DragNDrop")
include(CPack)
endif()
Loading

0 comments on commit 41d64dc

Please sign in to comment.