CMakeLists.txt 10.1 KB
Newer Older
1
project( tint2 )
2
cmake_minimum_required( VERSION 2.8.5 )
3

o9000's avatar
o9000 committed
4 5
option( ENABLE_BATTERY "Enable battery status plugin" ON )
option( ENABLE_TINT2CONF "Enable tint2conf build, a GTK+2 theme configurator for tint2" ON )
6
option( ENABLE_EXTRA_THEMES "Install additional tint2 themes" ON )
o9000's avatar
o9000 committed
7
option( ENABLE_RSVG "Rsvg support (launcher only)" ON )
8
option( ENABLE_SN "Startup notification support" ON )
o9000's avatar
o9000 committed
9
option( ENABLE_TRACING "Build tint2 with tracing instrumentation" OFF )
10
option( ENABLE_ASAN "Build tint2 with AddressSanitizer" OFF )
o9000's avatar
o9000 committed
11 12
option( ENABLE_BACKTRACE "Dump a backtrace in case of fatal errors (e.g. X11 I/O error)" OFF )
option( ENABLE_BACKTRACE_ON_SIGNAL "Dump a backtrace also when receiving signals such as SIGSEGV" OFF )
13 14 15
if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
  option( ENABLE_UEVENT "Kernel event handling support" ON )
endif( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
o9000's avatar
o9000 committed
16

17 18 19 20 21 22 23 24
include( GNUInstallDirs )
if(NOT docdir)
  set(docdir ${CMAKE_INSTALL_DOCDIR})
endif()
if(NOT htmldir)
  set(htmldir ${docdir}/html)
endif()

25
include( FindPkgConfig )
26
include( CheckLibraryExists )
o9000's avatar
o9000 committed
27
include( CheckCSourceCompiles )
28
pkg_check_modules( X11 REQUIRED x11 xcomposite xdamage xinerama xrender xrandr>=1.3 )
29 30 31 32 33
pkg_check_modules( PANGOCAIRO REQUIRED pangocairo )
pkg_check_modules( PANGO REQUIRED pango )
pkg_check_modules( CAIRO REQUIRED cairo )
pkg_check_modules( GLIB2 REQUIRED glib-2.0 )
pkg_check_modules( GOBJECT2 REQUIRED gobject-2.0 )
34
pkg_check_modules( IMLIB2 REQUIRED imlib2>=1.4.2 )
35

36 37 38 39
if(ENABLE_BACKTRACE)
	check_c_source_compiles(
		"#include <stdlib.h>\n#include <execinfo.h>\nint main () { backtrace(NULL, 0); }"
		BACKTRACE_LIBC)
o9000's avatar
o9000 committed
40

41 42
	if(BACKTRACE_LIBC)
		set(BACKTRACE_LIBC_FOUND TRUE)
43
		set(BACKTRACE_L_FLAGS "-rdynamic")
44
	else()
45 46 47 48 49 50 51 52 53 54 55 56 57 58
		pkg_check_modules( UNWIND libunwind )
		find_library(EXECINFO_LIBRARIES NAMES execinfo)
		if(EXECINFO_LIBRARIES OR EXECINFO_LIBRARIES_FOUND)
			set(EXECINFO_FOUND TRUE)
			set(EXECINFO_LIBRARIES "-lexecinfo")
			set(BACKTRACE_L_FLAGS "-rdynamic")
		else()
			set(EXECINFO_LIBRARIES "")
			set(BACKTRACE_L_FLAGS "")
		endif()
	endif()

	if( NOT BACKTRACE_LIBC_FOUND AND NOT UNWIND_FOUND AND NOT EXECINFO_FOUND )
	  message( WARNING "Backtrace support not available. You can enable it by installing libexecinfo or libunwind." )
59
	endif()
60 61 62
else()
	set(EXECINFO_LIBRARIES "")
	set(BACKTRACE_L_FLAGS "")
o9000's avatar
o9000 committed
63 64
endif()

65
if( ENABLE_RSVG )
o9000's avatar
o9000 committed
66
pkg_check_modules( RSVG librsvg-2.0>=2.14.0 )
67 68 69
endif( ENABLE_RSVG )

if( ENABLE_SN )
70
pkg_check_modules( SN libstartup-notification-1.0>=0.12 )
71
endif(ENABLE_SN)
72

73
find_library( RT_LIBRARY rt )
74

75
if( NOT X11_FOUND OR NOT PANGOCAIRO_FOUND OR NOT PANGO_FOUND OR NOT CAIRO_FOUND OR NOT GLIB2_FOUND OR NOT GOBJECT2_FOUND OR NOT IMLIB2_FOUND )
76
  message( FATAL_ERROR "Not all dependencies fulfilled. See https://gitlab.com/o9000/tint2/wikis/Install" )
77
endif( NOT X11_FOUND OR NOT PANGOCAIRO_FOUND OR NOT PANGO_FOUND OR NOT CAIRO_FOUND OR NOT GLIB2_FOUND OR NOT GOBJECT2_FOUND OR NOT IMLIB2_FOUND )
78

79
string( REPLACE ";" " " FLAGS_REPLACED "${IMLIB2_LDFLAGS}" )
80
set( CMAKE_REQUIRED_FLAGS "${FLAGS_REPLACED}" )
81
check_library_exists( "${IMLIB2_LIBRARIES}" "imlib_context_set_display" "${IMLIB2_LIBRARY_DIRS}" IMLIB_BUILD_WITH_X )
82
if( NOT IMLIB_BUILD_WITH_X )
o9000's avatar
o9000 committed
83
  message( FATAL_ERROR "Imlib is not built with X support" )
84 85
endif( NOT IMLIB_BUILD_WITH_X )

o9000's avatar
o9000 committed
86

87 88 89 90 91
add_definitions( -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_WITH_GETLINE )

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  add_definitions( -D_POSIX_C_SOURCE=200809L )
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
o9000's avatar
o9000 committed
92

93

94 95
include_directories( ${PROJECT_BINARY_DIR}
                     src
96
                     src/battery
97 98 99
                     src/clock
                     src/systray
                     src/taskbar
thilor77's avatar
thilor77 committed
100
                     src/launcher
101 102
                     src/tooltip
                     src/util
103
                     src/execplugin
o9000's avatar
o9000 committed
104
                     src/button
105
                     src/freespace
Oskari Rauta's avatar
Oskari Rauta committed
106
                     src/separator
107 108 109 110 111 112
                     ${X11_INCLUDE_DIRS}
                     ${PANGOCAIRO_INCLUDE_DIRS}
                     ${PANGO_INCLUDE_DIRS}
                     ${CAIRO_INCLUDE_DIRS}
                     ${GLIB2_INCLUDE_DIRS}
                     ${GOBJECT2_INCLUDE_DIRS}
113
                     ${IMLIB2_INCLUDE_DIRS}
114 115
                     ${RSVG_INCLUDE_DIRS}
                     ${SN_INCLUDE_DIRS} )
116

117 118 119
set( SOURCES src/config.c
             src/panel.c
             src/server.c
o9000's avatar
o9000 committed
120 121 122
             src/main.c
             src/init.c
             src/signals.c
o9000's avatar
o9000 committed
123
             src/tracing.c
o9000's avatar
o9000 committed
124 125
             src/mouse_actions.c
             src/drag_and_drop.c
126 127
             src/clock/clock.c
             src/systray/systraybar.c
thilor77's avatar
thilor77 committed
128
             src/launcher/launcher.c
129 130
             src/launcher/apps-common.c
             src/launcher/icon-theme-common.c
131 132
             src/launcher/xsettings-client.c
             src/launcher/xsettings-common.c
133 134
             src/taskbar/task.c
             src/taskbar/taskbar.c
135
             src/taskbar/taskbarname.c
136
             src/tooltip/tooltip.c
137
             src/execplugin/execplugin.c
o9000's avatar
o9000 committed
138
             src/button/button.c
139
             src/freespace/freespace.c
Oskari Rauta's avatar
Oskari Rauta committed
140
             src/separator/separator.c
141
             src/tint2rc.c
142
             src/util/area.c
143
             src/util/common.c
o9000's avatar
o9000 committed
144
             src/util/fps_distribution.c
145
             src/util/strnatcmp.c
146
             src/util/timer.c
147
             src/util/cache.c
o9000's avatar
o9000 committed
148 149
             src/util/color.c
             src/util/gradient.c
150
             src/util/uevent.c
151 152
             src/util/window.c )

153
if( ENABLE_BATTERY )
154 155 156 157
  set( SOURCES ${SOURCES} src/battery/battery.c)

  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set( SOURCES ${SOURCES} src/battery/linux.c)
158 159
  elseif(CMAKE_SYSTEM_NAME STREQUAL "DragonFly")
    set( SOURCES ${SOURCES} src/battery/freebsd.c)
160 161 162 163 164 165 166 167 168 169
  elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
    set( SOURCES ${SOURCES} src/battery/freebsd.c)
  elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
    set( SOURCES ${SOURCES} src/battery/openbsd.c)
  elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
    set( SOURCES ${SOURCES} src/battery/openbsd.c)
  else(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set( SOURCES ${SOURCES} src/battery/dummy.c)
  endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")

170 171 172 173 174 175
  add_definitions( -DENABLE_BATTERY )
endif( ENABLE_BATTERY )

if( ENABLE_RSVG )
  if( RSVG_FOUND )
	add_definitions( -DHAVE_RSVG )
o9000's avatar
o9000 committed
176 177
  else()
    message( FATAL_ERROR "SVG support enabled yet dependency not fulfilled: librsvg-2.0" )
178 179 180
  endif( RSVG_FOUND )
endif( ENABLE_RSVG )

181 182 183
if( ENABLE_SN )
  if( SN_FOUND )
    add_definitions( -DHAVE_SN -DSN_API_NOT_YET_FROZEN )
o9000's avatar
o9000 committed
184 185
  else()
    message( FATAL_ERROR "Startup notification support enabled yet dependency not fulfilled: libstartup-notification-1.0" )
186 187
  endif( SN_FOUND )
endif( ENABLE_SN)
188

189 190 191 192
if( ENABLE_UEVENT )
  add_definitions( -DENABLE_UEVENT )
endif( ENABLE_UEVENT )

193 194 195 196 197 198 199 200
if(ENABLE_BACKTRACE)
	if(BACKTRACE_LIBC_FOUND)
	  add_definitions( -DENABLE_EXECINFO )
	endif()

	if( UNWIND_FOUND )
	  add_definitions( -DENABLE_LIBUNWIND )
	endif( UNWIND_FOUND )
o9000's avatar
o9000 committed
201

202 203 204
	if( EXECINFO_FOUND )
	  add_definitions( -DENABLE_EXECINFO )
	endif( EXECINFO_FOUND )
o9000's avatar
o9000 committed
205

206 207 208 209 210 211
	if(ENABLE_BACKTRACE_ON_SIGNAL)
		add_definitions( -DBACKTRACE_ON_SIGNAL )
	endif()
else()
	add_definitions( -DDISABLE_BACKTRACE )
endif()
o9000's avatar
o9000 committed
212

213
if( ENABLE_TINT2CONF )
214
  add_definitions( -DHAVE_VERSION_H )
215
  add_subdirectory( src/tint2conf )
216
  add_dependencies( tint2conf version )
217
endif( ENABLE_TINT2CONF )
218

219
if( ENABLE_ASAN )
o9000's avatar
o9000 committed
220 221
  SET(ASAN_C_FLAGS " -O0 -g3 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic -Wshadow")
  SET(ASAN_L_FLAGS " -O0 -g3 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic -fuse-ld=gold ")
222
else()
223 224
  SET(ASAN_C_FLAGS "")
  SET(ASAN_L_FLAGS "")
225 226
endif()

o9000's avatar
o9000 committed
227 228 229 230 231 232 233 234 235
if( ENABLE_TRACING )
  add_definitions( -DHAVE_TRACING )
  SET(TRACING_C_FLAGS " -finstrument-functions -finstrument-functions-exclude-file-list=tracing.c -finstrument-functions-exclude-function-list=get_time,gettime -O0 -g3 -fno-common -fno-omit-frame-pointer -rdynamic")
  SET(TRACING_L_FLAGS " -O0 -g3 -fno-common -fno-omit-frame-pointer -rdynamic")
else()
  SET(TRACING_C_FLAGS "")
  SET(TRACING_L_FLAGS "")
endif()

236
add_custom_target( version ALL "${PROJECT_SOURCE_DIR}/get_version.sh" -- "\"${PROJECT_SOURCE_DIR}/\"" )
237

238 239 240 241 242 243
link_directories( ${X11_LIBRARY_DIRS}
                  ${PANGOCAIRO_LIBRARY_DIRS}
                  ${PANGO_LIBRARY_DIRS}
                  ${CAIRO_LIBRARY_DIRS}
                  ${GLIB2_LIBRARY_DIRS}
                  ${GOBJECT2_LIBRARY_DIRS}
244
                  ${IMLIB2_LIBRARY_DIRS}
245 246
                  ${RSVG_LIBRARY_DIRS}
                  ${SN_LIBRARY_DIRS} )
247
add_executable(tint2 ${SOURCES})
248 249 250 251 252 253
target_link_libraries( tint2 ${X11_LIBRARIES}
                             ${PANGOCAIRO_LIBRARIES}
                             ${PANGO_LIBRARIES}
                             ${CAIRO_LIBRARIES}
                             ${GLIB2_LIBRARIES}
                             ${GOBJECT2_LIBRARIES}
o9000's avatar
o9000 committed
254 255 256
							 ${IMLIB2_LIBRARIES}
							 ${UNWIND_LIBRARIES}
							 ${EXECINFO_LIBRARIES} )
257 258 259 260 261 262
if( ENABLE_RSVG )
  target_link_libraries( tint2 ${RSVG_LIBRARIES} )
endif( ENABLE_RSVG )
if( ENABLE_SN )
  target_link_libraries( tint2 ${SN_LIBRARIES} )
endif( ENABLE_SN )
263 264 265
if( RT_LIBRARY )
  target_link_libraries( tint2 ${RT_LIBRARY} )
endif( RT_LIBRARY )
266

267 268
target_link_libraries( tint2 m )

269
add_dependencies( tint2 version )
o9000's avatar
o9000 committed
270 271
set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=c99 ${ASAN_C_FLAGS} ${TRACING_C_FLAGS}" )
set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${ASAN_L_FLAGS} ${BACKTRACE_L_FLAGS}  ${TRACING_L_FLAGS}" )
272 273

install( TARGETS tint2 DESTINATION bin )
274 275
install( FILES tint2.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps )
install( FILES tint2.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications )
o9000's avatar
o9000 committed
276
install( FILES themes/tint2rc DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/tint2 )
277 278 279 280 281
install( FILES default_icon.png DESTINATION ${CMAKE_INSTALL_DATADIR}/tint2 )
install( FILES AUTHORS ChangeLog README.md doc/tint2.md DESTINATION ${docdir} )
install( FILES doc/manual.html doc/readme.html DESTINATION ${htmldir} )
install( DIRECTORY doc/images DESTINATION ${htmldir} )
install( FILES doc/tint2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
282
if( ENABLE_EXTRA_THEMES )
283 284
  add_subdirectory(themes)
endif( ENABLE_EXTRA_THEMES )