~midori/midori/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>

cmake_minimum_required(VERSION 2.6)
cmake_policy(VERSION 2.6)
# Work-around a bug in the included FindGettext fixed with 2.8.8
# See http://www.cmake.org/pipermail/cmake-commits/2012-February/012117.html
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.8")
    cmake_policy(SET CMP0002 OLD)
endif ()
project(midori C)
add_definitions("-DPACKAGE_NAME=\"${CMAKE_PROJECT_NAME}\"")
add_definitions("-DPACKAGE_BUGREPORT=\"https://bugs.launchpad.net/midori\"")

set(VERSION 0.5.8)
add_definitions("-DMIDORI_VERSION_SUFFIX=\"${VERSION}\"")
 
string(REPLACE "." ";" VERSION_LIST ${VERSION})
LIST(GET VERSION_LIST 0 MIDORI_MAJOR_VERSION)
add_definitions("-DMIDORI_MAJOR_VERSION=${MIDORI_MAJOR_VERSION}")
LIST(GET VERSION_LIST 1 MIDORI_MINOR_VERSION)
add_definitions("-DMIDORI_MINOR_VERSION=${MIDORI_MINOR_VERSION}")
LIST(GET VERSION_LIST 2 MIDORI_MICRO_VERSION)
add_definitions("-DMIDORI_MICRO_VERSION=${MIDORI_MICRO_VERSION}")

execute_process(COMMAND "bzr" "revno"
                OUTPUT_VARIABLE REVISION
                ERROR_QUIET
                OUTPUT_STRIP_TRAILING_WHITESPACE)
if (REVISION)
    set(VERSION "${VERSION}~r${REVISION}")
    # All warnings are errors in development builds
    set(VALAFLAGS ${VALAFLAGS} --fatal-warnings)
    set(CFLAGS "${CFLAGS}")
endif ()
add_definitions("-DPACKAGE_VERSION=\"${VERSION}\"")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Disallow building during install to avoid permission problems
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)

find_package(Vala REQUIRED)
vala_require("0.16.0")
set(VALAFLAGS ${VALAFLAGS}
    --enable-deprecated
    --debug
    )

include(GNUInstallDirs)
set(DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
add_definitions("-DMDATADIR=\"${DATADIR}\"")
add_definitions("-DSYSCONFDIR=\"${CMAKE_INSTALL_FULL_SYSCONFDIR}\"")
add_definitions("-DLIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"")
add_definitions("-DDOCDIR=\"${CMAKE_INSTALL_FULL_DOCDIR}\"")

add_definitions("-DENABLE_NLS=1")
add_definitions("-DLOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\"")

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "/* # generated file (stub) */")
add_definitions("-DHAVE_CONFIG_H=1")

find_file (UNISTD unistd.h)
if (UNISTD)
    add_definitions("-DHAVE_UNISTD_H")
endif ()

if (UNIX)
    find_file (SIGNAL signal.h)
    if (SIGNAL)
        add_definitions("-DHAVE_SIGNAL_H")
    endif ()
endif ()

find_library (X11 X11)
if (X11)
    # Pass /usr/X11R6/include for OpenBSD
    find_file (SCRNSAVER X11/extensions/scrnsaver.h /usr/X11R6/include)
    find_library (XSS Xss /usr/lib/X11R6/lib)
    if (SCRNSAVER AND XSS)
        add_definitions("-DHAVE_X11_EXTENSIONS_SCRNSAVER_H")
        set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${XSS};${X11}")
    endif ()
endif ()

if (WIN32)
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_WIN32)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_FREEBSD)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_DRAGONFLY)
    set(DFLY 1)
endif ()

if (APPLE)
    add_definitions("-DHAVE_OSX=1")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_OSX)
else ()
    add_definitions("-DHAVE_OSX=0")
endif ()

# Check if execinfo.h header exists
string(FIND ${CMAKE_SYSTEM_NAME} "BSD" BEGIN)
if (${BEGIN} GREATER 0)
    string(SUBSTRING ${CMAKE_SYSTEM_NAME} ${BEGIN} 3 BSD)
else()
    set(BSD 0)
endif()
if (UNIX AND NOT BSD AND NOT DFLY)
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_EXECINFO_H)
endif ()

find_package(PkgConfig)
pkg_check_modules(DEPS REQUIRED
                  libxml-2.0>=2.6
                  sqlite3>=3.6.19
                  gmodule-2.0
                  gio-2.0>=2.32.3
                  libsoup-gnome-2.4>=2.27.90
                  )
add_definitions("-DHAVE_LIBXML")
add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"")
add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-gnome-2.4_VERSION}\"")
set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4)
if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.29.91")
    add_definitions("-DHAVE_LIBSOUP_2_29_91")
endif ()
if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.34.0")
    add_definitions("-DHAVE_LIBSOUP_2_34_0")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_34_0)
endif ()
if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.37.1")
    add_definitions("-DHAVE_LIBSOUP_2_37_1")
endif ()
if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.40.0")
    # valac 0.16 didn't have the bindings yet
    # For consistency we need to ensure C code makes the same assumptions
    if (${VALA_VERSION} VERSION_GREATER "0.17.0")
        add_definitions("-DHAVE_LIBSOUP_2_40_0")
        set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_40_0)
    endif ()
endif ()

if (WIN32)
    add_definitions("-DLIBNOTIFY_VERSION=\"No\"")
else ()
    pkg_check_modules(NOTIFY REQUIRED libnotify)
    add_definitions("-DLIBNOTIFY_VERSION=\"${NOTIFY_VERSION}\"")
    add_definitions("-DHAVE_LIBNOTIFY")
    set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${NOTIFY_INCLUDE_DIRS}")
    set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${NOTIFY_LIBRARIES}")
    set(PKGS ${PKGS} libnotify)
endif ()

option(USE_GTK3 "Use GTK+3" OFF)
option(HALF_BRO_INCOM_WEBKIT2 "Serve as a guniea pig" OFF)
option(USE_ZEITGEIST "Zeitgeist history integration" ON)
option(USE_GRANITE "Fancy notebook and pop-overs" OFF)
option(USE_APIDOCS "API documentation" OFF)
option(USE_GIR "Generate GObject Introspection bindings" OFF)
option(EXTRA_WARNINGS "Additional compiler warnings" OFF)

# GTK+3 is implied here, whether set or not
if (USE_GRANITE OR HALF_BRO_INCOM_WEBKIT2)
    set(USE_GTK3 ON)
endif ()

if (USE_GRANITE)
    pkg_check_modules(GRANITE granite>=0.2)
    set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GRANITE_INCLUDE_DIRS}")
    set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GRANITE_LIBRARIES}")
    add_definitions("-DHAVE_GRANITE")
    add_definitions("-DGRANITE_VERSION=\"${GRANITE_VERSION}\"")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_GRANITE)
    set(PKGS ${PKGS} granite)
else ()
    add_definitions("-DGRANITE_VERSION=\"No\"")
endif()

if (USE_ZEITGEIST)
    pkg_check_modules(ZEITGEIST zeitgeist-1.0>=0.3.14)
    set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${ZEITGEIST_INCLUDE_DIRS}")
    set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${ZEITGEIST_LIBRARIES}")
    add_definitions("-DHAVE_ZEITGEIST")
    set(PKGS ${PKGS} zeitgeist-1.0)
endif()

if (USE_GTK3)
    pkg_check_modules(GCR gcr-3>=2.32)
    if (GCR_VERSION)
        set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GCR_INCLUDE_DIRS}")
        set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GCR_LIBRARIES}")
        add_definitions("-DGCR_VERSION=\"${GCR_VERSION}\"")
        add_definitions("-DHAVE_GCR")
        set(VALAFLAGS ${VALAFLAGS} -D HAVE_GCR)
    else ()
        add_definitions("-DGCR_VERSION=\"No\"")
    endif ()
else ()
    add_definitions("-DGCR_VERSION=\"No\"")
endif ()

if (HALF_BRO_INCOM_WEBKIT2)
    # Note: WebKitGTK+ 2.0.0 matches 1.11.91; 1.11.92 > 2.0.0
    pkg_check_modules(DEPS_GTK REQUIRED
                      gtk+-3.0>=3.0.0
                      webkit2gtk-3.0>=1.11.91
                      javascriptcoregtk-3.0
                      )
    add_definitions("-DHAVE_WEBKIT2")
    add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")
    add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit2gtk-3.0_VERSION}\"")
    set(PKGS ${PKGS} gtk+-3.0)
    set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-3.0.vapi")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2)
    if (${DEPS_GTK_webkit2gtk-3.0_VERSION} VERSION_GREATER "2.3.90")
        set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91)
    endif ()
elseif (USE_GTK3)
    pkg_check_modules(DEPS_GTK REQUIRED
                      gtk+-3.0>=3.0.0
                      webkitgtk-3.0>=1.8.1
                      javascriptcoregtk-3.0
                      )
    add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")
    add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkitgtk-3.0_VERSION}\"")
    set(PKGS ${PKGS} gtk+-3.0)
    set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi")
    set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
else ()
    pkg_check_modules(DEPS_GTK REQUIRED
                      gtk+-2.0>=2.24.0
                      webkit-1.0>=1.8.1
                      javascriptcoregtk-1.0
                      )
    add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-2.0_VERSION}\"")
    add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit-1.0_VERSION}\"")
    set(PKGS ${PKGS} gtk+-2.0)
    set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi")
endif ()

# dh_translations detects this if there's no variable used
set (GETTEXT_PACKAGE "midori")
add_definitions("-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\"")

set(CFLAGS "${CFLAGS} -Wall -Wundef -Wno-deprecated-declarations -g")

if (EXTRA_WARNINGS)
    LIST(APPEND EXTRA_CFLAGS_LIST
        -Wextra
        -Wno-unused-parameter
        -Wno-missing-field-initializers
        -Wno-comment
        -Waggregate-return
        -Wredundant-decls
        -Wshadow -Wpointer-arith -Wcast-align
        -Winline -Wformat-security -fno-common
        -Winit-self -Wundef
        -Wnested-externs
    )
    string(REPLACE ";" " " EXTRA_CFLAGS "${EXTRA_CFLAGS_LIST}")
    set(CFLAGS "${CFLAGS} ${EXTRA_CFLAGS}")
else ()
    if (REVISION)
        set(CFLAGS "${CFLAGS} -Werror")
    endif()
endif ()

# Explicitly add -fPIC for older toolchains
set(VALA_CFLAGS "-w -g -fPIC")

set(LIBMIDORI "${CMAKE_PROJECT_NAME}-core")

# CMake provides no uninstall target by design
add_custom_target (uninstall
    COMMAND "xargs" "rm" "-v" "<" "install_manifest.txt")

install(FILES AUTHORS COPYING ChangeLog EXPAT README DESTINATION ${CMAKE_INSTALL_DOCDIR})

add_subdirectory (midori)
add_subdirectory (extensions)
enable_testing()
add_subdirectory (tests)
add_subdirectory (po)
add_subdirectory (icons)
add_subdirectory (data)
add_subdirectory (config)

if (USE_APIDOCS)
    add_subdirectory (docs/api)
endif ()
if (USE_GIR)
    add_subdirectory (gir)
endif ()