CMakeLists.txt 7.23 KB
Newer Older
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
1
2
project( oxygen-gtk )

3
4
cmake_minimum_required(VERSION 2.4)

5
###########################
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
6
# Define package generation
7
8
###########################

Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
9
10
set( CPACK_PACKAGE_NAME "oxygen-gtk" )
set( CPACK_SOURCE_PACKAGE_NAME "oxygen-gtk" )
11
set( CPACK_SOURCE_GENERATOR TBZ2 )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
12
13
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Oxygen Gtk theme" )
set( CPACK_PACKAGE_VENDOR "hugo@oxygen-icons.org" )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
14
set( CPACK_PACKAGE_VERSION_MAJOR "1" )
15
set( CPACK_PACKAGE_VERSION_MINOR "1" )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
16
set( CPACK_PACKAGE_VERSION_PATCH "6" )
17
18
set( CPACK_SOURCE_IGNORE_FILES "build" "^${PROJECT_SOURCE_DIR}.*/.git/" )

19
20
21
22
##################################
# Define oxygen-gtk version string
##################################
if( EXISTS "${CMAKE_SOURCE_DIR}/.git" )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
23
24
25
    execute_process(COMMAND sh -c "cd ${CMAKE_SOURCE_DIR} && git describe 2>/dev/null"
        OUTPUT_VARIABLE OXYGEN_VERSION
        OUTPUT_STRIP_TRAILING_WHITESPACE)
26
endif( EXISTS "${CMAKE_SOURCE_DIR}/.git" )
27
28
STRING(COMPARE NOTEQUAL "${OXYGEN_VERSION}" "" OXYGEN_VERSION_DETECTED )
if( NOT OXYGEN_VERSION_DETECTED )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
29
    set( OXYGEN_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} )
30
endif( NOT OXYGEN_VERSION_DETECTED )
31
message( "Detected oxygen version string: ${OXYGEN_VERSION}" )
32

33
set( CPACK_SOURCE_PACKAGE_FILE_NAME "oxygen-gtk-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
34
include( CPack )
35
36
37
38
########################
# Package specific flags
########################

39
# Set to 1 to enable debugging information
40
if( NOT DEFINED OXYGEN_DEBUG )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
41
    set( OXYGEN_DEBUG 0 )
42
endif( NOT DEFINED OXYGEN_DEBUG )
43

44
45
# Set to 1 to enable debug logs regarding inner shadows
if( NOT DEFINED OXYGEN_DEBUG_INNERSHADOWS )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
46
    set( OXYGEN_DEBUG_INNERSHADOWS 0 )
47
48
endif( NOT DEFINED OXYGEN_DEBUG_INNERSHADOWS )

49
50
# Set to 1 to replace gtk stock icons
# with oxygen-icons
51
if( NOT DEFINED OXYGEN_ICON_HACK )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
52
    set( OXYGEN_ICON_HACK 1 )
53
endif( NOT DEFINED OXYGEN_ICON_HACK )
54

Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
55
# Set to 1 to force KDE icons and fonts when running in non-KDE
56
if( NOT DEFINED OXYGEN_FORCE_KDE_ICONS_AND_FONTS )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
57
    set( OXYGEN_FORCE_KDE_ICONS_AND_FONTS 1 )
58
endif( NOT DEFINED OXYGEN_FORCE_KDE_ICONS_AND_FONTS )
59

60
61
# Set to 1 to resize combobox list to compensate for combobox button glow width
# (may result in flicker on combo popup)
62
if( NOT DEFINED ENABLE_COMBOBOX_LIST_RESIZE )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
63
    set( ENABLE_COMBOBOX_LIST_RESIZE 1 )
64
endif( NOT DEFINED ENABLE_COMBOBOX_LIST_RESIZE )
65

66
# Set to 0 to disable inner shadows hack
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
67
# Note this flag is automatically set to 0 if GTK version is too old (< 2.24.2)
68
if( NOT DEFINED ENABLE_INNER_SHADOWS_HACK )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
69
    set( ENABLE_INNER_SHADOWS_HACK 1 )
70
endif( NOT DEFINED ENABLE_INNER_SHADOWS_HACK )
71

72
73
# set to 0 to disable groupbox hack
if( NOT DEFINED ENABLE_GROUPBOX_HACK )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
74
    set( ENABLE_GROUPBOX_HACK 1 )
75
76
endif( NOT DEFINED ENABLE_GROUPBOX_HACK )

77
78
79
80
##############
# Requirements
##############

81
# install prefix
82
include( UsePkgConfig )
83
84
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
85
86
87
88
    exec_program(
        ${PKGCONFIG_EXECUTABLE}
        ARGS --variable=prefix gtk+-2.0
        OUTPUT_VARIABLE GTK_PREFIX )
89

90
  	message( "Info: using PKGCONFIG_EXECUTABLE to set the installation prefix" )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
91
92
93
    set(CMAKE_INSTALL_PREFIX
        ${GTK_PREFIX} CACHE PATH "GTK install prefix" FORCE
        )
94
endif()
95

96
97
98
99
100
101
# X11
find_package( X11 REQUIRED )

# PKG_CONFIG
find_package(PkgConfig REQUIRED )

102
# GTK
103
pkg_check_modules( GTK REQUIRED gtk+-2.0 )
104

105
# Cairo
106
pkg_check_modules( CAIRO REQUIRED cairo )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
107

108
# DBus
109
set( HAVE_DBUS 0 )
110
pkg_check_modules( DBUS dbus-glib-1 )
111
if( DBUS_FOUND )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
112
    set( HAVE_DBUS 1 )
113
endif()
114

115
##########################
116
# installation directories
117
##########################
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
118
exec_program(
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
119
120
121
    ${PKGCONFIG_EXECUTABLE}
    ARGS --variable=gtk_binary_version gtk+-2.0
    OUTPUT_VARIABLE GTK_BIN_VERSION )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
122

123
124
125
if( DEFINED LIB_SUFFIX OR NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )

 	message( "Info: using LIB_SUFFIX to set the theme engine installation path" )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
126
    set( INSTALL_PATH_GTK_ENGINES "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/gtk-2.0/${GTK_BIN_VERSION}/engines" CACHE PATH "The directory in which to install the theme engine library( eg. /usr/lib/gtk-2.0/2.4.0/engines )" )
127
128
129

else()

Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
130
131
132
133
    exec_program(
        ${PKGCONFIG_EXECUTABLE}
        ARGS --variable=libdir gtk+-2.0
        OUTPUT_VARIABLE GTK_LIBDIR_PREFIX )
134
135

 	message( "Info: using PKGCONFIG_EXECUTABLE to set the theme engine installation path" )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
136
    set( INSTALL_PATH_GTK_ENGINES "${GTK_LIBDIR_PREFIX}/gtk-2.0/${GTK_BIN_VERSION}/engines" CACHE PATH "The directory in which to install the theme engine library( eg. /usr/lib/gtk-2.0/2.4.0/engines )" )
137
138
139

endif()

140
set( INSTALL_PATH_GTK_THEMES "${CMAKE_INSTALL_PREFIX}/share/themes" CACHE PATH "The directory in which to install the theme data( eg. /usr/share/themes )" )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
141
set( GTK_THEME_DIR ${INSTALL_PATH_GTK_THEMES}/oxygen-gtk )
142

Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
143
144
145
# First emit all warnings in one place
# Warn user if dbus-glib not found
if( NOT DBUS_FOUND )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
146
    message( "Warning: dbus-glib-1 <http://dbus.freedesktop.org/releases/dbus-glib/> could not be found on your system.\nD-Bus is a simple inter-process communication system. It is used for GTK applications to be updated on the fly when KDE configuration is changed." )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
147
148
149
endif( NOT DBUS_FOUND )

# Adjust flags based on gtk version and warn user if needed
150
if( ENABLE_INNER_SHADOWS_HACK AND GTK_VERSION VERSION_LESS 2.24.2 )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
151
152
    message( "Warning: disabling inner shadows hack because GTK version is too old (needed 2.24.2, found ${GTK_VERSION})" )
    set( ENABLE_INNER_SHADOWS_HACK 0 )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
153
endif( ENABLE_INNER_SHADOWS_HACK AND GTK_VERSION VERSION_LESS 2.24.2 )
154

155
156
157
#########
# summary
#########
158
159
message( "Flags: " )
message( "  OXYGEN_DEBUG ${OXYGEN_DEBUG}" )
160
message( "  OXYGEN_DEBUG_INNERSHADOWS ${OXYGEN_DEBUG_INNERSHADOWS}" )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
161
message( "  HAVE_DBUS ${HAVE_DBUS}" )
162
163
message( "  OXYGEN_ICON_HACK ${OXYGEN_ICON_HACK}" )
message( "  OXYGEN_FORCE_KDE_ICONS_AND_FONTS ${OXYGEN_FORCE_KDE_ICONS_AND_FONTS}" )
164
message( "  ENABLE_COMBOBOX_LIST_RESIZE ${ENABLE_COMBOBOX_LIST_RESIZE}" )
165
message( "  ENABLE_INNER_SHADOWS_HACK ${ENABLE_INNER_SHADOWS_HACK}" )
166
message( "  ENABLE_GROUPBOX_HACK ${ENABLE_GROUPBOX_HACK}" )
167
message( "" )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
168
message( "Paths: " )
169
170
171
172
message( "  Installing the GTK theme engine library to: ${INSTALL_PATH_GTK_ENGINES}" )
message( "  Installing the GTK theme engine data to: ${GTK_THEME_DIR}" )
message( "" )

173
174
175
176
177
178
179
180
181
182
183
184
##################
# uninstall target
##################
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)

add_custom_target(uninstall
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)


185
######################################################################
186
# Setup definitions and directories to be used for linking and include
187
######################################################################
188
link_directories( ${GTK_LIBRARY_DIRS} ${CAIRO_LIBRARY_DIRS} ${DBUS_LIBRARY_DIRS} )
Ruslan Kabatsayev's avatar
Ruslan Kabatsayev committed
189
include_directories( ${GTK_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} ${X11_X11_INCLUDE_PATH} )
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
190

191
#############################
192
# generate configuration file
193
#############################
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
194
195
configure_file( config.h.cmake ${CMAKE_BINARY_DIR}/config.h )

196
################
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
197
# Subdirectories
198
################
Hugo Pereira Da Costa's avatar
Hugo Pereira Da Costa committed
199
200
add_subdirectory( src )
add_subdirectory( rc )
201
add_subdirectory( special-icons )
202
add_subdirectory( demo )