Group names can also contain -
[debian/pino.git] / CMakeLists.txt
1 # Copyright (C) 2010 Cristian Greco <cristian@regolo.cc>
2 # Distributed under the same license terms of the program itself (see COPYING).
3
4 cmake_minimum_required(VERSION 2.6)
5
6 project("pino" C)
7
8 set(VERSION "0.2.10")
9
10 set(APPNAME "pino")
11 set(PACKAGE "${APPNAME}")
12 set(PACKAGE_NAME "${APPNAME}")
13 set(PACKAGE_STRING "${APPNAME}-${VERSION}")
14 set(PACKAGE_VERSION "${APPNAME}-${VERSION}")
15 set(APP_VERSION "${VERSION}")
16 set(GETTEXT_PACKAGE "${APPNAME}")
17 string(REGEX REPLACE "([0-9])\\.([0-9]).*" "\\1.\\2" VERSION_MAJOR_MINOR ${VERSION})
18 file(READ AUTHORS _AUTHORS)
19 string(REPLACE "\n" "\\n" AUTHORS ${_AUTHORS})
20
21 configure_file(
22   "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
23   "${CMAKE_CURRENT_BINARY_DIR}/config.h"
24 )
25 add_definitions(-include config.h)
26
27
28 configure_file(
29   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
30   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
31   IMMEDIATE @ONLY
32 )
33 add_custom_target(uninstall "${CMAKE_COMMAND}" -P
34   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
35
36
37 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
38 include(ValaVersion)
39 include(ValaPrecompile)
40 find_package(Vala REQUIRED)
41 ensure_vala_version("0.7.9" MINIMUM)
42
43
44 option(ENABLE_DEBUG "Enable debug messages" OFF)
45 option(UBUNTU_ICONS "Install icons for Ubuntu mono themes" OFF)
46 set(pino_VALA_OPTIONS)
47
48
49 find_package(PkgConfig)
50 pkg_check_modules(GLIB REQUIRED "glib-2.0 >= 2.14.0")
51 pkg_check_modules(GOBJECT REQUIRED "gobject-2.0 >= 2.14.0")
52 pkg_check_modules(GTK+ REQUIRED "gtk+-2.0 >= 2.10.0")
53 pkg_check_modules(GEE REQUIRED "gee-1.0 >= 0.5.0")
54 pkg_check_modules(GIO REQUIRED "gio-2.0 >= 2.0")
55 pkg_check_modules(LIBNOTIFY REQUIRED "libnotify")
56 pkg_check_modules(LIBSOUP REQUIRED "libsoup-2.4 >= 2.4")
57 pkg_check_modules(LIBXML REQUIRED "libxml-2.0 >= 2.0")
58 pkg_check_modules(WEBKIT REQUIRED "webkit-1.0 >= 1.0")
59 pkg_check_modules(LIBUNIQUE REQUIRED "unique-1.0 >= 1.0")
60 pkg_check_modules(GTKSPELL REQUIRED "gtkspell-2.0 >= 2.0")
61 pkg_check_modules(LIBINDICATE "indicate >= 0.3")
62
63 if(${LIBINDICATE_FOUND})
64   message(STATUS "libindicate found, support enabled...")
65   set(pino_VALA_OPTIONS ${pino_VALA_OPTIONS} -D LIBINDICATE)
66 else()
67   message(STATUS "libindicate not found, support disabled...")
68 endif()
69
70
71 if(ENABLE_DEBUG)
72   set(pino_VALA_OPTIONS ${pino_VALA_OPTIONS} -D HAS_DEBUG)
73 endif()
74 if(UBUNTU_ICONS)
75   set(pino_VALA_OPTIONS ${pino_VALA_OPTIONS} -D HAS_UBUNTUICONS)
76 endif()
77
78
79 file(GLOB pino_VALA_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.vala")
80 list(REMOVE_ITEM pino_VALA_SOURCES "src/oauth-client.vala")
81
82
83 vala_precompile(
84 pino_C_SOURCES
85   ${pino_VALA_SOURCES}
86 PACKAGES
87   glib-2.0
88   gobject-2.0
89   gtk+-2.0
90   gee-1.0
91   gio-2.0
92   libnotify
93   libsoup-2.4
94   libxml-2.0
95   webkit-1.0
96   unique-1.0
97 OPTIONS
98   ${pino_VALA_OPTIONS}
99 CUSTOM_VAPIS
100   ${CMAKE_CURRENT_SOURCE_DIR}/src/vapi/config.vapi
101 )
102
103
104 add_definitions(
105   ${GLIB_CFLAGS}
106   ${GOBJECT_CFLAGS}
107   ${GTK+_CFLAGS}
108   ${GEE_CFLAGS}
109   ${GIO_CFLAGS}
110   ${LIBNOTIFY_CFLAGS}
111   ${LIBSOUP_CFLAGS}
112   ${LIBXML_CFLAGS}
113   ${WEBKIT_CFLAGS}
114   ${LIBUNIQUE_CFLAGS}
115   ${GTKSPELL_CFLAGS}
116   ${LIBINDICATE_CFLAGS}
117 )
118
119 link_libraries(
120   ${GLIB_LIBRARIES}
121   ${GOBJECT_LIBRARIES}
122   ${GTK+_LIBRARIES}
123   ${GEE_LIBRARIES}
124   ${GIO_LIBRARIES}
125   ${LIBNOTIFY_LIBRARIES}
126   ${LIBSOUP_LIBRARIES}
127   ${LIBXML_LIBRARIES}
128   ${WEBKIT_LIBRARIES}
129   ${LIBUNIQUE_LIBRARIES}
130   ${GTKSPELL_LIBRARIES}
131   ${LIBINDICATE_LIBRARIES}
132 )
133
134 include_directories(src/vapi/)
135 add_definitions(-std=c99)
136
137 add_executable(pino
138   ${pino_C_SOURCES}
139   #src/vapi/sha1.c
140   src/vapi/time_parser.c
141 )
142
143 install(TARGETS pino DESTINATION bin)
144
145
146 find_program(MSGFMT_EXECUTABLE msgfmt)
147 file(GLOB PO_FILES "po/*.po")
148 set(MO_FILES)
149 foreach(PO_FILE ${PO_FILES})
150   get_filename_component(PO_FILE_BASE ${PO_FILE} NAME_WE)
151   set(MO_FILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/po)
152   set(MO_FILE ${MO_FILE_PATH}/${PO_FILE_BASE}.mo)
153
154   file(MAKE_DIRECTORY "${MO_FILE_PATH}")
155   add_custom_command(
156     OUTPUT ${MO_FILE}
157     COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_FILE} ${PO_FILE})
158
159   install(FILES ${MO_FILE}
160     DESTINATION share/locale/${PO_FILE_BASE}/LC_MESSAGES
161     RENAME ${GETTEXT_PACKAGE}.mo)
162   set(MO_FILES ${MO_FILES} ${MO_FILE})
163 endforeach()
164 add_custom_target(locales ALL DEPENDS ${MO_FILES})
165
166
167 set(pino_IMAGES
168   img/delete_status.png
169   img/direct_fresh.svg
170   img/direct_reply.png
171   img/direct.svg
172   img/favorite_no.png
173   img/favorite.png
174   img/mentions_fresh.svg
175   img/mentions.svg
176   img/progress.gif
177   img/reply.png
178   img/re_tweet.png
179   img/timeline_fresh.svg
180   img/timeline.svg
181   img/userpic.svg
182 )
183 install(FILES ${pino_IMAGES} DESTINATION share/pino/icons)
184
185
186 set(pino_ICONS
187   img/pino_fresh.svg
188   img/pino.svg
189 )
190 install(FILES ${pino_ICONS} DESTINATION share/icons/hicolor/scalable/apps)
191
192
193 set(pino_UBUNTU_ICONS_DARK
194  img/ubuntu-mono-dark/pino-tray-icon.svg
195  img/ubuntu-mono-dark/pino-tray-icon-fresh.svg
196 )
197 set(pino_UBUNTU_ICONS_LIGHT
198   img/ubuntu-mono-light/pino-tray-icon.svg
199   img/ubuntu-mono-light/pino-tray-icon-fresh.svg
200 )
201 if(UBUNTU_ICONS)
202   install(FILES ${pino_UBUNTU_ICONS_DARK} DESTINATION share/icons/ubuntu-mono-dark/apps/22)
203   install(FILES ${pino_UBUNTU_ICONS_LIGHT} DESTINATION share/icons/ubuntu-mono-light/apps/22)
204 endif()
205
206
207 set(pino_DOCS
208   COPYING
209   README
210   AUTHORS
211   INSTALL
212 )
213 install(FILES ${pino_DOCS} DESTINATION share/doc/pino)
214
215
216 set(pino_TEMPLATES
217   templates/main.tpl
218   templates/status.tpl
219   templates/status_direct.tpl
220   templates/status_me.tpl
221 )
222 install(FILES ${pino_TEMPLATES} DESTINATION share/pino/templates)
223
224
225 install(FILES pino.desktop DESTINATION share/applications)
226 install(FILES indicator/pino DESTINATION share/indicators/messages/applications)