transmission/gtk/CMakeLists.txt

246 lines
6.4 KiB
CMake
Raw Normal View History

find_program(APPSTREAM appstreamcli)
add_executable(${TR_NAME}-gtk WIN32)
target_sources(${TR_NAME}-gtk
PRIVATE
Actions.cc
Actions.h
Application.cc
Application.h
DetailsDialog.cc
DetailsDialog.h
Dialogs.cc
Dialogs.h
FaviconCache.cc
FileList.cc
FileList.h
FilterBar.cc
FilterBar.h
FilterBase.h
FilterBase.hh
FilterListModel.h
FilterListModel.hh
Flags.h
FreeSpaceLabel.cc
FreeSpaceLabel.h
GtkCompat.h
HigWorkarea.h
IconCache.cc
IconCache.h
ListModelAdapter.cc
ListModelAdapter.h
main.cc
MainWindow.cc
MainWindow.h
MakeDialog.cc
MakeDialog.h
MessageLogWindow.cc
MessageLogWindow.h
Notify.cc
Notify.h
OptionsDialog.cc
OptionsDialog.h
PathButton.cc
PathButton.h
Percents.cc
Percents.h
Prefs.cc
Prefs.h
PrefsDialog.cc
PrefsDialog.h
RelocateDialog.cc
RelocateDialog.h
Session.cc
Session.h
SorterBase.h
SorterBase.hh
SortListModel.h
SortListModel.hh
StatsDialog.cc
StatsDialog.h
SystemTrayIcon.cc
SystemTrayIcon.h
Torrent.cc
Torrent.h
TorrentCellRenderer.cc
TorrentCellRenderer.h
TorrentFilter.cc
TorrentFilter.h
TorrentSorter.cc
TorrentSorter.h
Utils.cc
Utils.h)
target_sources(${TR_NAME}-gtk
PRIVATE
ui/gtk3/AddTrackerDialog.ui
ui/gtk3/DetailsDialog.ui
ui/gtk3/EditTrackersDialog.ui
ui/gtk3/FilterBar.ui
ui/gtk3/MainWindow.ui
ui/gtk3/MakeDialog.ui
ui/gtk3/MakeProgressDialog.ui
ui/gtk3/MessageLogWindow.ui
ui/gtk3/OptionsDialog.ui
ui/gtk3/PrefsDialog.ui
ui/gtk3/RelocateDialog.ui
ui/gtk3/StatsDialog.ui
ui/gtk3/TorrentUrlChooserDialog.ui)
source_group(Ui/GTK3
REGULAR_EXPRESSION [[ui/gtk3/.*\.ui$]])
target_sources(${TR_NAME}-gtk
PRIVATE
ui/gtk4/AddTrackerDialog.ui
ui/gtk4/DetailsDialog.ui
ui/gtk4/EditTrackersDialog.ui
ui/gtk4/FilterBar.ui
ui/gtk4/MainWindow.ui
ui/gtk4/MakeDialog.ui
ui/gtk4/MakeProgressDialog.ui
ui/gtk4/MessageLogWindow.ui
ui/gtk4/OptionsDialog.ui
ui/gtk4/PrefsDialog.ui
ui/gtk4/RelocateDialog.ui
ui/gtk4/StatsDialog.ui
ui/gtk4/TorrentUrlChooserDialog.ui)
source_group(Ui/GTK4
REGULAR_EXPRESSION [[ui/gtk4/.*\.ui$]])
if(WITH_APPINDICATOR)
set_property(
SOURCE SystemTrayIcon.cc
APPEND
PROPERTY COMPILE_DEFINITIONS
HAVE_APPINDICATOR)
if(APPINDICATOR_IS_AYATANA)
set_property(
SOURCE SystemTrayIcon.cc
APPEND
PROPERTY COMPILE_DEFINITIONS
APPINDICATOR_IS_AYATANA)
endif()
endif()
Add support for GTK 4 (#3916) * Make compact mode switch work for both GTK 3 and 4 * Implement GTK 4-specific view gesture handling * Fix torrents view context menu on GTK 4 * Explicitly show/hide menubar on startup/teardown * Switch from `Gtk::Pixbuf` to `Gio::Icon` for views * Support GTK 4 exceptions based on `std::exception` * Fix options menu setup with GTK 4 * Use `delete-event` (GTK 3) and `close-request` (GTK 4) signals to handle window clousure * Add custom file chooser button implementation GTK 4 drops FileChooserButton widget and suggests implementing it using Button. * Add helpers to set X11 hints with GTK 4 * Remove `HigWorkarea` class that's no longer used * Make main menu shortcuts work with GTK 4 * Make drops work in main window and make dialog with GTK 4 * Remove unused `gtr_action_get_widget()` helper * Fix text direction mark setup with GTK 4 (due to switch to enum class) * Fix file tree font size calculation with GTK 4 * Fix crash during shutdown with GTK 4 * Switch from `RadioButton` to `CheckButton` for compatibility with GTK 4 * Fix opening files with GTK 4 * Rework torrent cell renderer to support both GTK 3 and 4 * Disable system tray icon support with GTK 4 * Fix windows positioning with GTK 4 * Fix focus event handling with GTK 4 * Adapt to tree model row/iterator changes in GTK 4 * Adapt to toplevel/root window changes in GTK 4 * Adapt to clipboard changes in GTK 4 * Adapt to icon/theme changes in GTK 4 * Adapt to file/path changes in GTK 4 * Random leftover fixes for GTK 4 compatibility * Clean up unused code * Move GTK 3 *.ui files into a subdirectory * Add GTK 4 *.ui files * Search for both GTK 3 and 4 during configuration
2022-10-08 22:50:03 +00:00
if(GTK_VERSION EQUAL 4)
set(UI_SUBDIR ui/gtk4)
else()
set(UI_SUBDIR ui/gtk3)
endif()
tr_target_glib_resources(${TR_NAME}-gtk
transmission.gresource.xml
${UI_SUBDIR}/transmission-ui.gresource.xml)
if(ENABLE_NLS)
set(DESKTOP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TR_NAME}-gtk.desktop")
tr_gettext_msgfmt(${TR_NAME}-gtk
${DESKTOP_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/transmission-gtk.desktop.in)
target_sources(${TR_NAME}-gtk
PRIVATE
${DESKTOP_FILE})
set(METAINFO_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TR_NAME}-gtk.metainfo.xml")
tr_gettext_msgfmt(${TR_NAME}-gtk
${METAINFO_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/transmission-gtk.metainfo.xml.in)
target_sources(${TR_NAME}-gtk
PRIVATE
${METAINFO_FILE})
endif()
target_compile_definitions(${TR_NAME}-gtk
PRIVATE
TRANSMISSIONLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
GETTEXT_PACKAGE="${TR_NAME}-gtk"
$<$<BOOL:${ENABLE_UTP}>:WITH_UTP>)
if(NOT ENABLE_DEPRECATED)
target_compile_definitions(${TR_NAME}-gtk
PRIVATE
G_DISABLE_DEPRECATED
GDK_PIXBUF_DISABLE_DEPRECATED
GDK_DISABLE_DEPRECATED
GTK_DISABLE_DEPRECATED
PANGO_DISABLE_DEPRECATED
GDKMM_DISABLE_DEPRECATED
GIOMM_DISABLE_DEPRECATED
GLIBMM_DISABLE_DEPRECATED
GTKMM_DISABLE_DEPRECATED
PANGOMM_DISABLE_DEPRECATED
SIGCXX_DISABLE_DEPRECATED)
endif()
target_compile_options(${TR_NAME}-gtk
PRIVATE
$<$<BOOL:${ENABLE_WERROR}>:$<IF:$<CXX_COMPILER_ID:MSVC>,/WX,-Werror>>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-exit-time-destructors>)
target_include_directories(${TR_NAME}-gtk
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${TR_NAME}-gtk SYSTEM
PRIVATE
$<$<BOOL:${WITH_APPINDICATOR}>:${APPINDICATOR_INCLUDE_DIRS}>)
target_link_libraries(${TR_NAME}-gtk
PRIVATE
${TR_NAME}
transmission::gtk_impl
fmt::fmt-header-only
$<$<BOOL:${WITH_APPINDICATOR}>:${APPINDICATOR_LIBRARIES}>)
if(MSVC)
tr_append_target_property(${TR_NAME}-gtk LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
tr_win32_app_info(${TR_NAME}-gtk
"Transmission GTK+ Client"
"${TR_NAME}-gtk"
"${TR_NAME}-gtk.exe"
"${TR_NAME}.ico")
install(
TARGETS ${TR_NAME}-gtk
DESTINATION ${CMAKE_INSTALL_BINDIR})
set(PUBLIC_ICONS
hicolor_apps_scalable_transmission.svg
hicolor_apps_scalable_transmission-devel.svg
hicolor_apps_symbolic_transmission-symbolic.svg)
set(ICON_NAME_REGEX "^([^_]+)_([^_]+)_([^_]+)_(.+)$")
foreach(ICON ${PUBLIC_ICONS})
string(REGEX REPLACE ${ICON_NAME_REGEX} "\\1/\\3/\\2" ICON_DIR ${ICON})
string(REGEX REPLACE ${ICON_NAME_REGEX} "\\4" ICON_NAME ${ICON})
install(
FILES icons/${ICON}
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/${ICON_DIR}/
RENAME ${ICON_NAME})
endforeach()
if(INSTALL_DOC)
install(
FILES ${TR_NAME}-gtk.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif()
if(ENABLE_NLS)
install(
FILES ${DESKTOP_FILE}
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(
FILES ${METAINFO_FILE}
DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
else()
install(
FILES transmission-gtk.desktop.in
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
RENAME ${TR_NAME}-gtk.desktop)
endif()