2022-12-14 16:11:32 +00:00
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MACOS_SUPPORT_MINIMUM)
message(FATAL_ERROR "Targeting macOS versions before ${MACOS_SUPPORT_MINIMUM} is not supported for the macOS project, please adjust CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET})")
2022-11-13 12:02:07 +00:00
endif()
2023-01-01 19:49:48 +00:00
set(MAC_BUNDLE_NAME Transmission)
2018-09-30 10:37:30 +00:00
2022-11-12 20:01:57 +00:00
add_compile_options(
-fcxx-modules
-fmodules
2023-01-01 19:49:48 +00:00
-fobjc-arc
# #warnings are good practice in development
"-Wno-#warnings"
# GNU extensions are good practice in Objective-C
-Wno-gnu)
2022-06-29 00:15:52 +00:00
2022-11-12 20:01:57 +00:00
find_program(ACTOOL_EXECUTABLE actool REQUIRED)
find_program(CODESIGN_EXECUTABLE codesign REQUIRED)
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
add_subdirectory(QuickLookPlugin)
add_subdirectory(VDKQueue)
add_executable(${TR_NAME}-mac MACOSX_BUNDLE)
target_sources(${TR_NAME}-mac
PRIVATE
AboutWindowController.h
AboutWindowController.mm
AddMagnetWindowController.h
AddMagnetWindowController.mm
AddWindowController.h
AddWindowController.mm
Badger.h
Badger.mm
BadgeView.h
BadgeView.mm
BlocklistDownloader.h
BlocklistDownloader.mm
BlocklistDownloaderViewController.h
BlocklistDownloaderViewController.mm
BlocklistScheduler.h
BlocklistScheduler.mm
BonjourController.h
BonjourController.mm
ButtonToolbarItem.h
ButtonToolbarItem.mm
CocoaCompatibility.h
ColorTextField.h
ColorTextField.mm
Controller.h
Controller.mm
CreatorWindowController.h
CreatorWindowController.mm
DragOverlayView.h
DragOverlayView.mm
DragOverlayWindow.h
DragOverlayWindow.mm
ExpandedPathToIconTransformer.h
ExpandedPathToIconTransformer.mm
ExpandedPathToPathTransformer.h
ExpandedPathToPathTransformer.mm
FileListNode.h
FileListNode.mm
FileNameCell.h
FileNameCell.mm
FileOutlineController.h
FileOutlineController.mm
FileOutlineView.h
FileOutlineView.mm
FilePriorityCell.h
FilePriorityCell.mm
FileRenameSheetController.h
FileRenameSheetController.mm
FilterBarController.h
FilterBarController.mm
FilterBarView.h
FilterBarView.mm
FilterButton.h
FilterButton.mm
GlobalOptionsPopoverViewController.h
GlobalOptionsPopoverViewController.mm
GroupPopUpButtonCell.h
GroupPopUpButtonCell.mm
GroupsController.h
GroupsController.mm
GroupsPrefsController.h
GroupsPrefsController.mm
GroupTextCell.h
GroupTextCell.mm
GroupToolbarItem.h
GroupToolbarItem.mm
InfoActivityViewController.h
InfoActivityViewController.mm
InfoFileViewController.h
InfoFileViewController.mm
InfoGeneralViewController.h
InfoGeneralViewController.mm
InfoOptionsViewController.h
InfoOptionsViewController.mm
InfoPeersViewController.h
InfoPeersViewController.mm
InfoTextField.h
InfoTextField.mm
InfoTrackersViewController.h
InfoTrackersViewController.mm
InfoViewController.h
InfoWindowController.h
InfoWindowController.mm
main.mm
MessageWindowController.h
MessageWindowController.mm
NSApplicationAdditions.h
NSApplicationAdditions.mm
NSDataAdditions.h
NSDataAdditions.mm
NSImageAdditions.h
NSImageAdditions.mm
NSKeyedUnarchiverAdditions.h
NSKeyedUnarchiverAdditions.mm
NSMutableArrayAdditions.h
NSMutableArrayAdditions.mm
NSStringAdditions.h
NSStringAdditions.mm
PeerProgressIndicatorCell.h
PeerProgressIndicatorCell.mm
PeerTableView.h
PeerTableView.mm
PiecesView.h
PiecesView.mm
PortChecker.h
PortChecker.mm
PredicateEditorRowTemplateAny.h
PredicateEditorRowTemplateAny.mm
PrefsController.h
PrefsController.mm
PrefsWindow.h
PrefsWindow.mm
PriorityPopUpButtonCell.h
PriorityPopUpButtonCell.mm
ProgressGradients.h
ProgressGradients.mm
ShareToolbarItem.h
ShareToolbarItem.mm
ShareTorrentFileHelper.h
ShareTorrentFileHelper.mm
SparkleProxy.mm
StatsWindowController.h
StatsWindowController.mm
StatusBarController.h
StatusBarController.mm
StatusBarView.h
StatusBarView.mm
Toolbar.h
Toolbar.mm
Torrent.h
Torrent.mm
TorrentCell.h
TorrentCell.mm
TorrentGroup.h
TorrentGroup.mm
TorrentTableView.h
TorrentTableView.mm
TrackerCell.h
TrackerCell.mm
TrackerNode.h
TrackerNode.mm
TrackerTableView.h
TrackerTableView.mm
URLSheetWindowController.h
URLSheetWindowController.mm
WebSeedTableView.h
WebSeedTableView.mm)
set(XIB_FILES
2016-09-10 17:08:58 +00:00
AboutWindow.xib
BlocklistStatusWindow.xib
FileRenameSheetController.xib
FilterBar.xib
InfoFileView.xib
InfoPeersView.xib
InfoTrackersView.xib
InfoWindow.xib
MessageWindow.xib
StatsWindow.xib
StatusBar.xib
2023-01-01 19:49:48 +00:00
URLSheetWindow.xib)
2021-04-24 21:55:11 +00:00
2023-01-01 19:49:48 +00:00
set(RESOURCES
2016-09-10 17:08:58 +00:00
Defaults.plist
Credits.rtf
sparkle_dsa_pub.pem
../COPYING
2023-01-01 19:49:48 +00:00
Images/TransmissionDocument.icns)
source_group(Resources
FILES ${RESOURCES})
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
set_source_files_properties(
${RESOURCES}
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
set(IMAGESETS
2016-09-10 17:08:58 +00:00
ActionHover
Bandwidth
CleanupTemplate
CompleteCheck
CreateLarge
DownArrowGroupTemplate
DownArrowTemplate
2022-11-12 20:01:57 +00:00
DownloadBadge
2022-06-12 04:24:31 +00:00
EllipsisTemplate
2016-09-10 17:08:58 +00:00
FavIcon
2022-11-12 20:01:57 +00:00
GearshapeTemplate
2016-09-10 17:08:58 +00:00
Globe
Groups
InfoActivity
InfoFiles
InfoGeneral
InfoOptions
InfoPeers
InfoTracker
Lock
Magnet
PauseHover
PauseOff
PauseOn
PinTemplate
PriorityControlHigh
PriorityControlLow
PriorityControlNormal
PriorityHighTemplate
PriorityLowTemplate
PriorityNormalTemplate
Remote
ResumeHover
ResumeNoWaitHover
ResumeNoWaitOff
ResumeNoWaitOn
ResumeOff
ResumeOn
RevealHover
RevealOff
RevealOn
ToolbarCreateTemplate
ToolbarFilterTemplate
ToolbarInfoTemplate
ToolbarOpenTemplate
ToolbarOpenWebTemplate
ToolbarPauseAllTemplate
ToolbarPauseSelectedTemplate
ToolbarRemoveTemplate
ToolbarResumeAllTemplate
ToolbarResumeSelectedTemplate
2022-05-27 11:59:37 +00:00
TortoiseTemplate
2022-06-05 14:54:45 +00:00
Transfers
2016-09-10 17:08:58 +00:00
UpArrowGroupTemplate
UpArrowTemplate
2022-11-12 20:01:57 +00:00
UploadBadge
2016-09-10 17:08:58 +00:00
YingYangGroupTemplate
2023-01-01 19:49:48 +00:00
YingYangTemplate)
2016-09-10 17:08:58 +00:00
2022-11-12 20:01:57 +00:00
set(APPICON_NAME AppIcon)
set(IMAGE_ASSETS_DIR Images/Images.xcassets)
set(APPICONSET_DIR "${IMAGE_ASSETS_DIR}/${APPICON_NAME}.appiconset")
set(IMAGE_ASSETS
${IMAGE_ASSETS_DIR}/Contents.json
${APPICONSET_DIR}/Contents.json)
2023-01-01 19:49:48 +00:00
foreach(IMG IN LISTS IMAGESETS)
2022-11-12 20:01:57 +00:00
set(IMG_DIR "${IMAGE_ASSETS_DIR}/${IMG}.imageset")
list(APPEND IMAGE_ASSETS
${IMG_DIR}/${IMG}.png
${IMG_DIR}/${IMG}@2x.png
${IMG_DIR}/Contents.json)
2016-09-10 17:08:58 +00:00
endforeach()
2022-11-12 20:01:57 +00:00
foreach(SIZE IN ITEMS 16 32 128 256 512)
list(APPEND IMAGE_ASSETS
${APPICONSET_DIR}/icon_${SIZE}x${SIZE}.png
${APPICONSET_DIR}/icon_${SIZE}x${SIZE}@2x.png)
endforeach()
set(COMPILED_IMAGE_ASSETS
"${CMAKE_CURRENT_BINARY_DIR}/${APPICON_NAME}.icns"
"${CMAKE_CURRENT_BINARY_DIR}/Assets.car")
add_custom_command(
OUTPUT
${COMPILED_IMAGE_ASSETS}
${APPICON_NAME}.Info.plist
2023-01-01 19:49:48 +00:00
COMMAND
${ACTOOL_EXECUTABLE}
2022-11-12 20:01:57 +00:00
--compile "${CMAKE_CURRENT_BINARY_DIR}"
--platform macosx
--minimum-deployment-target ${CMAKE_OSX_DEPLOYMENT_TARGET}
--app-icon ${APPICON_NAME}
--output-partial-info-plist "${CMAKE_CURRENT_BINARY_DIR}/${APPICON_NAME}.Info.plist"
${IMAGE_ASSETS_DIR}
DEPENDS ${IMAGE_ASSETS}
2023-01-01 19:49:48 +00:00
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
source_group("Generated Files"
FILES
${COMPILED_IMAGE_ASSETS}
${APPICON_NAME}.Info.plist)
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
list(APPEND RESOURCES
${COMPILED_IMAGE_ASSETS})
2022-11-12 20:01:57 +00:00
2023-01-01 19:49:48 +00:00
set_source_files_properties(
${COMPILED_IMAGE_ASSETS}
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
set(LINGUAS
2016-09-10 17:08:58 +00:00
da
de
2022-07-25 01:44:56 +00:00
en
2016-09-10 17:08:58 +00:00
es
fr
it
nl
pt_PT
ru
2023-01-01 19:49:48 +00:00
tr)
2016-09-10 17:08:58 +00:00
if(ENABLE_NLS)
2023-01-01 19:49:48 +00:00
set(ENABLED_LINGUAS ${LINGUAS})
2016-09-10 17:08:58 +00:00
else()
2023-01-01 19:49:48 +00:00
set(ENABLED_LINGUAS en)
2016-09-10 17:08:58 +00:00
endif()
2023-01-01 19:49:48 +00:00
set(BASE_XIB_FILES
2016-09-10 17:08:58 +00:00
AddMagnetWindow.xib
AddWindow.xib
Creator.xib
GlobalOptionsPopover.xib
GroupRules.xib
InfoActivityView.xib
InfoGeneralView.xib
InfoOptionsView.xib
MainMenu.xib
2023-01-01 19:49:48 +00:00
PrefsWindow.xib)
list(TRANSFORM BASE_XIB_FILES
PREPEND Base.lproj/)
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
set(LANG_STRINGS_FILES
2016-09-10 17:08:58 +00:00
InfoPlist.strings
2023-01-01 19:49:48 +00:00
Localizable.strings)
2016-09-10 17:08:58 +00:00
2023-01-01 19:49:48 +00:00
foreach(LANG ${ENABLED_LINGUAS})
set(${LANG}_STRINGS_FILES)
2022-07-25 01:44:56 +00:00
if(NOT LANG STREQUAL "en")
2023-01-01 19:49:48 +00:00
foreach(F ${BASE_XIB_FILES})
2022-07-25 01:44:56 +00:00
get_filename_component(F_BASE "${F}" NAME_WE)
2023-01-01 19:49:48 +00:00
list(APPEND ${LANG}_STRINGS_FILES ${LANG}.lproj/${F_BASE}.strings)
2022-07-25 01:44:56 +00:00
endforeach()
endif()
2023-01-01 19:49:48 +00:00
foreach(F ${LANG_STRINGS_FILES})
list(APPEND ${LANG}_STRINGS_FILES ${LANG}.lproj/${F})
2016-09-10 17:08:58 +00:00
endforeach()
2023-01-01 19:49:48 +00:00
source_group(Resources/${LANG}.lproj
FILES ${${LANG}_STRINGS_FILES})
2016-09-10 17:08:58 +00:00
endforeach()
2023-01-01 19:49:48 +00:00
foreach(LANG ${ENABLED_LINGUAS})
list(APPEND RESOURCES ${${LANG}_STRINGS_FILES})
2022-11-12 20:01:57 +00:00
set(STRINGS_FILES_RESOURCES_DIR Resources)
if(NOT CMAKE_GENERATOR STREQUAL Xcode)
string(APPEND STRINGS_FILES_RESOURCES_DIR /${LANG}.lproj)
endif()
2023-01-01 19:49:48 +00:00
set_source_files_properties(
${${LANG}_STRINGS_FILES}
PROPERTIES
MACOSX_PACKAGE_LOCATION ${STRINGS_FILES_RESOURCES_DIR})
2016-09-10 17:08:58 +00:00
endforeach()
2023-01-01 19:49:48 +00:00
target_sources(${TR_NAME}-mac
PRIVATE
${RESOURCES})
tr_target_xib_files(${TR_NAME}-mac
${XIB_FILES}
${BASE_XIB_FILES})
find_library(SPARKLE_FRAMEWORK Sparkle
PATHS ${CMAKE_CURRENT_SOURCE_DIR}
NO_DEFAULT_PATHS)
2016-09-10 17:08:58 +00:00
target_link_libraries(${TR_NAME}-mac
2023-01-01 19:49:48 +00:00
PRIVATE
${TR_NAME}
2023-01-02 16:23:51 +00:00
fmt::fmt-header-only
2023-01-01 19:49:48 +00:00
vdkqueue
${SPARKLE_FRAMEWORK}
"-framework AppKit"
"-framework Carbon"
"-framework Foundation"
"-framework IOKit"
"-framework Quartz"
"-framework Security"
"-weak_framework UserNotifications")
2016-09-10 17:08:58 +00:00
2022-11-12 20:01:57 +00:00
if(NOT CMAKE_GENERATOR STREQUAL Xcode)
2023-01-01 19:49:48 +00:00
add_custom_command(
TARGET ${TR_NAME}-mac
POST_BUILD
2022-11-24 17:20:48 +00:00
COMMAND ${CODESIGN_EXECUTABLE} -s - $<TARGET_BUNDLE_DIR:${TR_NAME}-mac>)
2022-11-12 20:01:57 +00:00
endif()
2023-01-01 19:49:48 +00:00
set_target_properties(
${TR_NAME}-mac
PROPERTIES
OUTPUT_NAME ${MAC_BUNDLE_NAME}
MACOSX_BUNDLE_GUI_IDENTIFIER "org.m0k.transmission"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
INSTALL_RPATH "@executable_path;@executable_path/../Frameworks")
install(
TARGETS ${TR_NAME}-mac
DESTINATION Applications)
install(
DIRECTORY TransmissionHelp
DESTINATION Applications/${MAC_BUNDLE_NAME}.app/Contents/Resources)
2016-09-10 17:08:58 +00:00
tr_install_web(Applications/${MAC_BUNDLE_NAME}.app/Contents/Resources)
2023-01-01 19:49:48 +00:00
install(CODE
"list(APPEND CMAKE_MODULE_PATH \"${CMAKE_SOURCE_DIR}/cmake\")
2016-09-10 17:08:58 +00:00
include(TrMacros)
include(GetPrerequisites)
2023-01-01 19:49:48 +00:00
tr_fixup_bundle_item(
\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/Applications/${MAC_BUNDLE_NAME}.app\"
\"Contents/MacOS/${MAC_BUNDLE_NAME}\" \"${CMAKE_CURRENT_SOURCE_DIR}\")")