forked from tieto/gplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
231 lines (189 loc) · 5.92 KB
/
CMakeLists.txt
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
###############################################################################
# CMake Initialization
###############################################################################
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.8.0)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
if(${CMAKE_VERSION} VERSION_LESS "2.8.3")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Compatibility)
endif(${CMAKE_VERSION} VERSION_LESS "2.8.3")
if(${CMAKE_VERSION} VERSION_GREATER "3.0.0")
# allow reading of the LOCATION property
cmake_policy(SET CMP0026 OLD)
# don't force target names to match a pattern
cmake_policy(SET CMP0037 OLD)
endif(${CMAKE_VERSION} VERSION_GREATER "3.0.0")
###############################################################################
# Project Info
###############################################################################
project(gplugin C)
set(GPLUGIN_MAJOR_VERSION 0)
set(GPLUGIN_MINOR_VERSION 27)
set(GPLUGIN_MICRO_VERSION 0)
set(GPLUGIN_EXTRA_VERSION)
set(GPLUGIN_VERSION ${GPLUGIN_MAJOR_VERSION}.${GPLUGIN_MINOR_VERSION}.${GPLUGIN_MICRO_VERSION}${GPLUGIN_EXTRA_VERSION})
set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/locale)
add_definitions(-DLOCALEDIR="${LOCALE_DIR}")
###############################################################################
# Options
###############################################################################
option(
BUILD_GIR
"Whether or not to build a GObject Introspection type library"
"On"
)
option(
NLS
"Install translation files"
"On"
)
option(
TESTING_ENABLED
"Whether or not to run unit tests while compiling"
"On"
)
option(
BUILD_HELP2MAN
"Whether or not to build man pages from --help output"
"on"
)
###############################################################################
# Dependencies
###############################################################################
if(APPLE)
# homebrew stuff
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig")
# look for homebrew, if it's installed theres so more mucking we need to do
find_program(BREW
NAMES brew
DOC "brew executable"
)
if(BREW)
execute_process(
COMMAND ${BREW} --prefix libffi
OUTPUT_VARIABLE FFI_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(FFI_PREFIX)
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${FFI_PREFIX}/lib/pkgconfig")
endif(FFI_PREFIX)
execute_process(
COMMAND ${BREW} --prefix cairo
OUTPUT_VARIABLE CAIRO_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(CAIRO_PREFIX)
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CAIRO_PREFIX}/lib/pkgconfig")
endif(CAIRO_PREFIX)
endif(BREW)
# fink and macports
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/sw/lib/pkgconfig:/opt/local/lib/pkgconfig")
endif(APPLE)
include(GNUInstallDirs)
include(FindPkgConfig)
include(PkgConfigVariable)
if(BUILD_HELP2MAN)
include(help2man)
endif(BUILD_HELP2MAN)
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.34.0 gobject-2.0)
# we separate gmodule out so our test aren't linked to it
pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
pkg_config_variable(glib-2.0 glib_genmarshal GLIB_GENMARSHAL)
pkg_config_variable(glib-2.0 glib_mkenums GLIB_MKENUMS)
if(TESTING_ENABLED)
find_program(GTESTER
NAMES gtester
DOC "gtester executable"
)
mark_as_advanced(GTESTER)
find_program(XSLTPROC
NAMES xsltproc
DOC "xsltproc executable"
)
mark_as_advanced(XSLTPROC)
endif(TESTING_ENABLED)
###############################################################################
# NLS
###############################################################################
set(GETTEXT_PACKAGE gplugin)
add_definitions(-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}")
if(NLS)
include(Gettextize)
endif(NLS)
###############################################################################
# Build Info
###############################################################################
add_definitions(
-std=c99
-g -g3
-O2
-DPREFIX="${CMAKE_INSTALL_PREFIX}"
-DLIBDIR="${CMAKE_INSTALL_LIBDIR}"
-DGPLUGIN_WEBSITE="http://bitbucket.org/gplugin/main"
-Wall
-Werror=format-security
-Wformat
-Wextra
)
# check if we're using gcc
if(CMAKE_COMPILER_IS_GNUCC)
add_definitions(
-DGPLUGIN_UNUSED=__attribute__\(\(unused\)\)
-ggdb
)
else(CMAKE_COMPILER_IS_GNUCC)
add_definitions(
-DGPLUGIN_UNUSED=
)
endif(CMAKE_COMPILER_IS_GNUCC)
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR} # for built headers/sources
${CMAKE_BINARY_DIR}/gplugin # for gplugin.h
${GLIB_INCLUDE_DIRS}
${GMODULE_INCLUDE_DIRS}
)
link_directories(
${GLIB_LIBRARY_DIRS}
${GMODULE_LIBRARY_DIRS}
)
###############################################################################
# Subdirectories
###############################################################################
add_subdirectory(gplugin)
add_subdirectory(gplugin-gtk)
add_subdirectory(plugins)
add_subdirectory(po)
add_subdirectory(lua)
add_subdirectory(perl)
add_subdirectory(python)
###############################################################################
# Install stuff
###############################################################################
# documentation
install(FILES ChangeLog INSTALL README HACKING DESTINATION ${CMAKE_INSTALL_DOCDIR})
###############################################################################
# make dist
###############################################################################
set(ARCHIVES
gplugin-${GPLUGIN_VERSION}.tar.bz2
gplugin-${GPLUGIN_VERSION}.tar.gz
gplugin-${GPLUGIN_VERSION}.zip
)
set(SIGNATURES)
foreach(ARCHIVE ${ARCHIVES})
add_custom_command(
COMMAND hg archive ${ARCHIVE}
OUTPUT ${ARCHIVE}
DEPENDS .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_command(
COMMAND gpg --yes -abs ${ARCHIVE}
OUTPUT ${ARCHIVE}.asc
DEPENDS . ${ARCHIVE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
list(APPEND SIGNATURES ${ARCHIVE}.asc)
endforeach(ARCHIVE)
add_custom_target(dist DEPENDS ${ARCHIVES} ${SIGNATURES})