source: trunk/gtk/CMakeLists.txt @ 14496

Last change on this file since 14496 was 14496, checked in by mikedld, 7 years ago

Add version info to executables (on Windows). Group projects into folders (CMake).

File size: 4.9 KB
Line 
1project(trgtk)
2
3if(WITH_LIBAPPINDICATOR)
4    add_definitions(-DHAVE_LIBAPPINDICATOR)
5endif()
6
7execute_process(
8    COMMAND
9        ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_resources
10    OUTPUT_VARIABLE
11        GLIB_COMPILE_RESOURCES_EXECUTABLE
12    OUTPUT_STRIP_TRAILING_WHITESPACE
13)
14
15if(NOT GLIB_COMPILE_RESOURCES_EXECUTABLE)
16    message(SEND_ERROR "Unable to find glib-compile-resources executable")
17endif()
18
19add_custom_command(
20    OUTPUT
21        ${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.c
22        ${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.h
23    COMMAND
24        ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
25        --target=${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.c
26        --sourcedir=${CMAKE_CURRENT_SOURCE_DIR}
27        --generate-source
28        --c-name transmission
29        transmission.gresource.xml
30    COMMAND
31        ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
32        --target=${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.h
33        --sourcedir=${CMAKE_CURRENT_SOURCE_DIR}
34        --generate-header
35        --c-name transmission
36        transmission.gresource.xml
37    DEPENDS
38        transmission.gresource.xml
39        transmission-ui.xml
40    WORKING_DIRECTORY
41        ${CMAKE_CURRENT_SOURCE_DIR}
42)
43
44if(ENABLE_NLS)
45    find_program(INTLTOOL_MERGE_EXECUTABLE intltool-merge REQUIRED)
46    set(${PROJECT_NAME}_DESKTOP_FILE "${PROJECT_BINARY_DIR}/${TR_NAME}-gtk.desktop")
47    add_custom_command(
48        OUTPUT ${${PROJECT_NAME}_DESKTOP_FILE}
49        COMMAND ${INTLTOOL_MERGE_EXECUTABLE} --desktop-style --utf8 ${CMAKE_SOURCE_DIR}/po ${PROJECT_SOURCE_DIR}/transmission-gtk.desktop.in ${${PROJECT_NAME}_DESKTOP_FILE}
50        DEPENDS ${PROJECT_SOURCE_DIR}/transmission-gtk.desktop.in
51        VERBATIM
52    )
53endif()
54
55set(${PROJECT_NAME}_SOURCES
56    actions.c
57    conf.c
58    details.c
59    dialogs.c
60    favicon.c
61    file-list.c
62    filter.c
63    hig.c
64    icons.c
65    main.c
66    makemeta-ui.c
67    msgwin.c
68    notify.c
69    open-dialog.c
70    relocate.c
71    stats.c
72    torrent-cell-renderer.c
73    tr-core.c
74    tr-icon.c
75    tr-prefs.c
76    tr-window.c
77    util.c
78    ${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.c
79)
80
81set(${PROJECT_NAME}_HEADERS
82    actions.h
83    conf.h
84    details.h
85    dialogs.h
86    favicon.h
87    file-list.h
88    filter.h
89    hig.h
90    icon-lock.h
91    icon-logo-24.h
92    icon-logo-48.h
93    icon-ratio.h
94    icons.h
95    icon-turtle.h
96    icon-utilities.h
97    makemeta-ui.h
98    msgwin.h
99    notify.h
100    open-dialog.h
101    relocate.h
102    stats.h
103    torrent-cell-renderer.h
104    tr-core.h
105    tr-icon.h
106    tr-prefs.h
107    tr-window.h
108    util.h
109    ${CMAKE_CURRENT_BINARY_DIR}/transmission-resources.h
110)
111
112include_directories(
113    ${CMAKE_SOURCE_DIR}
114    ${PROJECT_BINARY_DIR}
115    ${GTK_INCLUDE_DIRS}
116    ${CURL_INCLUDE_DIRS}
117)
118
119link_directories(
120    ${GTK_LIBRARY_DIRS}
121)
122
123add_definitions(
124    "-DTRANSMISSIONLOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\""
125    "-DGETTEXT_PACKAGE=\"${TR_NAME}-gtk\""
126    -DG_DISABLE_DEPRECATED
127    -DGDK_PIXBUF_DISABLE_DEPRECATED
128    -DGDK_DISABLE_DEPRECATED
129    # FIXME: migrate from GtkUIManager to GtkBuilder in 2.90
130    # -DGTK_DISABLE_DEPRECATED
131    -DPANGO_DISABLE_DEPRECATED
132    # FIXME: these break libnotify's headers
133    # -DG_DISABLE_SINGLE_INCLUDES
134    # -DGTK_DISABLE_SINGLE_INCLUDES
135    ${GTK_CFLAGS_OTHER}
136)
137
138tr_win32_app_info(${PROJECT_NAME}_WIN32_RC_FILE
139    "Transmission GTK+ Client"
140    "${TR_NAME}-gtk"
141    "${TR_NAME}-gtk.exe"
142    "${TR_NAME}.ico")
143
144add_executable(${TR_NAME}-gtk WIN32
145    ${${PROJECT_NAME}_SOURCES}
146    ${${PROJECT_NAME}_HEADERS}
147    ${${PROJECT_NAME}_DESKTOP_FILE}
148    ${${PROJECT_NAME}_WIN32_RC_FILE}
149)
150
151target_link_libraries(${TR_NAME}-gtk
152    ${TR_NAME}
153    ${GTK_LIBRARIES}
154    ${CURL_LIBRARIES}
155    ${EVENT2_LIBRARIES}
156)
157
158if(MSVC)
159    tr_append_target_property(${TR_NAME}-gtk LINK_FLAGS "/ENTRY:mainCRTStartup")
160endif()
161
162install(TARGETS ${TR_NAME}-gtk DESTINATION ${CMAKE_INSTALL_BINDIR})
163
164set(${PROJECT_NAME}_PUBLIC_ICONS
165    hicolor_apps_16x16_transmission.png
166    hicolor_apps_22x22_transmission.png
167    hicolor_apps_24x24_transmission.png
168    hicolor_apps_32x32_transmission.png
169    hicolor_apps_48x48_transmission.png
170    hicolor_apps_256x256_transmission.png
171    hicolor_apps_scalable_transmission.svg
172)
173
174set(ICON_NAME_REGEX "^([^_]+)_([^_]+)_([^_]+)_(.+)$")
175foreach(ICON ${${PROJECT_NAME}_PUBLIC_ICONS})
176    string(REGEX REPLACE ${ICON_NAME_REGEX} "\\1/\\3/\\2" ICON_DIR ${ICON})
177    string(REGEX REPLACE ${ICON_NAME_REGEX} "\\4" ICON_NAME ${ICON})
178    install(FILES icons/${ICON} DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/${ICON_DIR}/ RENAME ${ICON_NAME})
179endforeach()
180
181if(INSTALL_DOC)
182    install(FILES ${TR_NAME}-gtk.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
183endif()
184
185if(ENABLE_NLS)
186    install(FILES ${${PROJECT_NAME}_DESKTOP_FILE} DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
187else()
188    install(FILES transmission-gtk.desktop.in DESTINATION ${CMAKE_INSTALL_DATADIR}/applications RENAME ${TR_NAME}-gtk.desktop)
189endif()
Note: See TracBrowser for help on using the repository browser.