summaryrefslogtreecommitdiff
blob: cd345a1cb624dd5cb68c186f1b51d6f71cd9c091 (plain)
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
########### requirements ###############

cmake_minimum_required (VERSION 2.6)
find_package (PkgConfig)
include (CheckLibraryExists)
include (CheckIncludeFiles)
include (CheckFunctionExists)
include (CheckSymbolExists)
include ("${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/GNUInstallDirs.cmake")

########### project ###############

project ("cairo-dock-plugins")
set (VERSION "3.0.0")

add_definitions (-std=c99 -Wextra -Wwrite-strings -Wuninitialized -Werror-implicit-function-declaration -Wstrict-prototypes) # removed for stable versions: -Wstrict-prototypes #-Wunreachable-code -Wno-unused-parameter -Wall
add_definitions (-DGL_GLEXT_PROTOTYPES="1")

############ sources tarball #############

set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION}")
set (CPACK_SOURCE_IGNORE_FILES
	"/build/;/.bzr/;bzrignore$;/misc/;~$;${CPACK_SOURCE_IGNORE_FILES}")
include (CPack)

add_custom_target(dist
	COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
add_custom_target(dist-bzr
	COMMAND bzr export ${CMAKE_PROJECT_NAME}-${VERSION}.tar.gz
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

########### global variables ###############

if( WIN32 )
	message(FATAL_ERROR "Cairo-Dock requires an air-conditioned room. Please close Windows!")
endif( WIN32 )

set (PACKAGE ${CMAKE_PROJECT_NAME})
set (GETTEXT_PACKAGE ${PACKAGE})

# get plug-ins install dir
execute_process(
    COMMAND pkg-config gldi --variable=pluginsdir  # /usr/lib/cairo-dock # or /usr/lib/x86_64-linux-gnu/cairo-dock
    OUTPUT_VARIABLE pluginsdir)
STRING (REGEX REPLACE "\n" "" pluginsdir ${pluginsdir})  # remove the \n
# get plug-ins data dir
execute_process(
    COMMAND pkg-config gldi --variable=pluginsdatadir  # /usr/share/cairo-dock/plug-ins
    OUTPUT_VARIABLE pluginsdatadir)
STRING (REGEX REPLACE "\n" "" pluginsdatadir ${pluginsdatadir})
# get prefix dir
execute_process(
    COMMAND pkg-config gldi --variable=prefix  # /usr/share/cairo-dock/plug-ins
    OUTPUT_VARIABLE prefix)
STRING (REGEX REPLACE "\n" "" prefix ${prefix})
# get GTK version (must be the same as the core, as GTK2 and GTK3 can't coexist at runtime)
execute_process(
    COMMAND pkg-config gldi --variable=gtkversion  # 2 or 3
    OUTPUT_VARIABLE gtkversion)
STRING (REGEX REPLACE "\n" "" gtkversion ${gtkversion})
# check that version matches with the core
execute_process(
    COMMAND pkg-config --modversion gldi  # 2.2.0-3
    OUTPUT_VARIABLE dock_version)
STRING (REGEX REPLACE "\n" "" dock_version ${dock_version})
if (NOT "${dock_version}" STREQUAL "${VERSION}")		# Version
	if ("${PACKAGEMENT}" STREQUAL "")
		MESSAGE (FATAL_ERROR "Error : version mismatch with the core : " ${VERSION} <> ${dock_version})
	else ()
		MESSAGE (WARNING "Warning : version mismatch with the core : " ${VERSION} <> ${dock_version})
	endif ()
endif()

# check that installation dir matches with the core
GET_FILENAME_COMPONENT(libdir "${pluginsdir}/.." ABSOLUTE)  # /usr/lib # or /usr/lib/x86_64-linux-gnu
GET_FILENAME_COMPONENT(datadir "${pluginsdatadir}/../.." ABSOLUTE)  # /usr/share
if (NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "${prefix}"
		OR NOT "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" STREQUAL "${libdir}"
		OR NOT "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}" STREQUAL "${datadir}")
	message (STATUS "It seems that the current CMAKE_INSTALL_{PREFIX,LIBDIR,DATAROOTDIR} flags are not the same that you have used with the core.")
	message (STATUS " It will be replaced by this value: ${prefix}")
	message (WARNING "Plug-ins should be installed in the same directory as the core, that is to say in ${pluginsdir}")
	set (CMAKE_INSTALL_PREFIX "${prefix}")
	#set (libdir "${CMAKE_INSTALL_PREFIX}/${libname}/cairo-dock")
endif()

# set internationalisation
set (GETTEXT_PLUGINS "cairo-dock-plugins")
set (localedir "${prefix}/${CMAKE_INSTALL_LOCALEDIR}")
set (gaugesdir "${datadir}/cairo-dock/gauges")

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")  # additionnal FindPackage files

########### dependencies ###############

message ("")
message (STATUS "=====================")
message (STATUS "Check dependencies...")
message (STATUS "=====================")
message ("")

pkg_check_modules ("PACKAGE" REQUIRED "cairo" "librsvg-2.0" "dbus-1" "dbus-glib-1" "libxml-2.0")
#pkg_check_modules ("PACKAGE" REQUIRED "ig")
pkg_check_modules ("GLDI" REQUIRED "gldi")  # we don't want to link with gldi, so we check it separately.
set (PACKAGE_INCLUDE_DIRS "${GLDI_INCLUDE_DIRS}")

add_definitions (-DGTK_DISABLE_DEPRECATED="1")

#############    GLIB    #################
pkg_check_modules (GLIB glib-2.0)
	STRING (REGEX REPLACE "\\..*" "" GLIB_MAJOR "${GLIB_VERSION}") # 2.28.3 => 2
	STRING (REGEX REPLACE "[0-9]*\\.([^ ]+)" "\\1" GLIB_MINOR "${GLIB_VERSION}")  # 2.28.3 => 2.28
	STRING (REGEX REPLACE "\\.[0-9]*" "" GLIB_MINOR "${GLIB_MINOR}") # 2.28 => 28
	STRING (REGEX REPLACE ".*\\." "" GLIB_NANO "${GLIB_VERSION}") # 2.28.3 => 3
	STRING (REGEX REPLACE "-.*" "" GLIB_NANO "${GLIB_NANO}")

############# DISKS #################
if (ENABLE_DISKS-PLUGIN)
	message (STATUS "> Disks:")
	set (GETTEXT_DISKS ${GETTEXT_PLUGINS})
	set (VERSION_DISKS "0.0.4")
	set (PACKAGE_DISKS "cd-disks")
	set (with_disks "yes")
	set (disksdatadir "${pluginsdatadir}/Disks")
	configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Disks/data/Disks.conf.in ${CMAKE_CURRENT_BINARY_DIR}/Disks/data/Disks.conf)
	add_subdirectory ("Disks")
else()
	set (with_disks "no")
endif()

############# DONCKY #################
if (ENABLE_DONCKY-PLUGIN)
	message (STATUS "> Doncky:")
	set (GETTEXT_DONCKY ${GETTEXT_PLUGINS})
	set (VERSION_DONCKY "0.0.6")
	set (PACKAGE_DONCKY "cd-doncky")
	set (with_doncky "yes")
	set (donckydatadir "${pluginsdatadir}/Doncky")
	configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doncky/data/Doncky.conf.in ${CMAKE_CURRENT_BINARY_DIR}/Doncky/data/Doncky.conf)
	add_subdirectory (Doncky)
else()
	set (with_doncky "no")
endif()

############## GVFS-INTEGRATION #################
#if (ENABLE_GNOME-INTEGRATION OR ENABLE_XFCE-INTEGRATION)
#	message (STATUS "> GVFS-Integration:")
#	pkg_check_modules ("LIBGIO" "gio-2.0")
#	add_subdirectory (gvfs-integration)
#endif()

############# KDE-INTEGRATION #################
if (ENABLE_NEWKDE-INTEGRATION)
	message (STATUS "> KDE-Integration:")
	set (with_kde_integration "no")
	#find_package(KDE4)
	find_package(Qt4)
	if (QT4_FOUND)
		message (STATUS " * Qt Includes: ${QT_INCLUDES}")
		message (STATUS " * Qt Definitions: ${QT_DEFINITIONS}")
		message (STATUS " * QtCore Library: ${QT_QTCORE_LIBRARY} / ${PACKAGE_LIBRARIES}")
	else()
		message (STATUS " * Qt unavailable")
	endif()

	find_path(KDECORE_INCLUDE_DIR "kdecore_export.h")
	find_library(KDECORE_LIBRARY NAMES "kdecore")
	GET_FILENAME_COMPONENT(KDECORE_LIBRARY ${KDECORE_LIBRARY} PATH)

	find_path(KIO_INCLUDE_DIR "kio_export.h" PATH_SUFFIXES "kio")
	find_library(KIO_LIBRARY NAMES "kio")
	GET_FILENAME_COMPONENT(KIO_LIBRARY ${KIO_LIBRARY} PATH)

	find_path(KDE_INCLUDE_DIR "KDirWatch" PATH_SUFFIXES "KDE")

	if (NOT "${KDECORE_LIBRARY}" STREQUAL "")
		message (STATUS " * KDECORE Dir: ${KDECORE_INCLUDE_DIR}")
		message (STATUS " * KDECORE Library: ${KDECORE_LIBRARY}")
	else()
		message (STATUS " * KDECORE unavailable")
	endif()
	if (NOT "${KIO_LIBRARY}" STREQUAL "")
		message (STATUS " * KIO Dir: ${KIO_INCLUDE_DIR}")
		message (STATUS " * KIO Library: ${KIO_LIBRARY}")
	else()
		message (STATUS " * KIO unavailable")
	endif()
	if (NOT "${KDE_LIBRARY}" STREQUAL "") ## always empty?
		message (STATUS " * KDE4 Dir: ${KDE_INCLUDE_DIR}")
		message (STATUS " * KDE4 Library: ${KDE_LIBRARY}")
	else()
		message (STATUS " * KDE4 unavailable")
	endif()

	if (QT4_FOUND
		 AND KDECORE_INCLUDE_DIR
		 AND KDECORE_LIBRARY
		 AND KIO_INCLUDE_DIR
		 AND KIO_LIBRARY
		 AND KDE_INCLUDE_DIR)
		message (STATUS "  KDE: OK")
		set (VERSION_KDE_INTEGRATION "0.0.3")
		set (PACKAGE_KDE_INTEGRATION "cd_kde-integration")
		set (with_kde_integration2 "yes")
		set (kde_integrationdatadir "${pluginsdatadir}/kde-integration2")
		add_subdirectory ("kde-integration2")
	else()
		message (STATUS "Could not find kde libs; Cairo-Dock won't be built with KDE support.")
		message (STATUS "These libraries are required to compile KDE experimental applet: kdecore, kio, kde4")
		set (MODULES_INTEGRATION_MISSING "${MODULES_INTEGRATION_MISSING} kdecore, kio, kde4")
	endif()
else()
	set (with_kde_integration2 "no")
endif()

############# NETWORK_MONITOR #################
if (ENABLE_NETWORK-MONITOR-PLUGIN)
	message (STATUS "> Network Monitor:")
	set (GETTEXT_NETWORK_MONITOR ${GETTEXT_PLUGINS})
	set (VERSION_NETWORK_MONITOR "0.2.6")
	set (PACKAGE_NETWORK_MONITOR "cd-network-monitor")
	set (with_network_monitor "yes")
	set (network_monitordatadir "${pluginsdatadir}/Network-Monitor")
	configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Network-Monitor/data/Network-Monitor.conf.in ${CMAKE_CURRENT_BINARY_DIR}/Network-Monitor/data/Network-Monitor.conf)
	add_subdirectory (Network-Monitor)
else()
	set (with_network_monitor "no")
endif()

############# SCOOBY_DO #################
if (ENABLE_SCOOBY-DO-PLUGIN)
	message (STATUS "> Scooby-Do:")
	set (GETTEXT_SCOOBY_DO ${GETTEXT_PLUGINS})
	set (VERSION_SCOOBY_DO "0.1.1")
	set (PACKAGE_SCOOBY_DO "cd-scooby-do")
	set (with_scooby_do "yes")
	set (scooby_dodatadir "${pluginsdatadir}/Scooby-Do")
	configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Scooby-Do/data/Scooby-Do.conf.in ${CMAKE_CURRENT_BINARY_DIR}/Scooby-Do/data/Scooby-Do.conf)
	add_subdirectory (Scooby-Do)
else()
	set (with_scooby_do "no")
endif()

message ("")
message (STATUS "===============")
message (STATUS "Plug-ins build:")
message (STATUS "===============")
message ("")
message (STATUS "Unstable:")
message (STATUS " - with Disks applet:              ${with_disks}")
message (STATUS " - with Doncky applet:             ${with_doncky}")
message (STATUS " - with KDE experimental support:  ${with_kde_integration2}")
message (STATUS " - with Network-Monitor applet:    ${with_network_monitor}")
message (STATUS " - with Scooby-Do applet:          ${with_scooby_do}")
message ("")