-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
372 lines (299 loc) · 12.7 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
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# Setting the name of the main project
PROJECT(KMyMoney)
# The CMake version we require
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
# This option will make 'make' very verbose
#SET(CMAKE_VERBOSE_MAKEFILE ON)
# cmake 2.6 proposed to add this policy
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# Our modules reside in the subdirectory cmake/modules/
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
######################### KMyMoney Version ##########################
# The current version of KMyMoney (used for packages and config.h)
SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "9")
SET(VERSION_PATCH "3")
# Get the date of the last change from the ChangeLog
SET(date_format "([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])")
FILE(STRINGS ${CMAKE_SOURCE_DIR}/ChangeLog LAST_CHANGE
REGEX ${date_format} LIMIT_COUNT 1 LENGTH_MINIMUM 10 LENGTH_MAXIMUM 10)
STRING(REGEX MATCH ${date_format} _ign "${LAST_CHANGE}")
SET(VERSION_SUFFIX "cvs${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}")
######################### General Requirements ##########################
FIND_PACKAGE(KDE3 REQUIRED)
FIND_PACKAGE(Perl REQUIRED)
# check for JPEG
FIND_PACKAGE(JPEG)
IF (JPEG_FOUND)
SET(HAVE_LIBJPEG 1)
ENDIF (JPEG_FOUND)
# check for PNGL
FIND_PACKAGE(PNG)
IF (PNG_FOUND)
SET(HAVE_LIBPNG 1)
ENDIF (PNG_FOUND)
# check for THREAD model
Find_PACKAGE(Threads)
IF (CMAKE_USE_PTHREADS_INIT)
SET(HAVE_LIBPTHREAD 1)
ENDIF (CMAKE_USE_PTHREADS_INIT)
# check for ZLIB
FIND_PACKAGE(ZLIB)
IF (ZLIB_FOUND)
SET(HAVE_LIBZ 1)
ENDIF (ZLIB_FOUND)
# check for PkgConfig
FIND_PACKAGE(PkgConfig)
# check for some modules we require
pkg_check_modules (PKGS libxml-2.0 libxml++-2.6 glib-2.0 glibmm-2.4)
# this sets variables like ${PKGS_INCLUDE_DIRS} ${PKGS_LIBRARY_DIRS}
# (cf. /usr/share/cmake/Modules/FindPkgConfig.cmake for more info)
# check some functions
INCLUDE (CheckFunctionExists)
CHECK_FUNCTION_EXISTS(atoll HAVE_ATOLL)
CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
SET(CMAKE_REQUIRED_FLAGS "-std=c99")
SET(CMAKE_REQUIRED_LIBRARIES m)
CHECK_FUNCTION_EXISTS(round HAVE_ROUND)
# check for function in header
INCLUDE(CheckSymbolExists)
SET(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
CHECK_SYMBOL_EXISTS(res_init "sys/types.h;netinet/in.h;arpa/nameser.h;resolv.h" HAVE_RES_INIT)
# check for res_init with prototype
INCLUDE(CheckPrototypeExists)
CHECK_PROTOTYPE_EXISTS(res_init "sys/types.h;netinet/in.h;arpa/nameser.h;resolv.h" HAVE_RES_INIT_PROTO)
# special handling of crypt() check
# ----------------------- crypt() ---------------------------------
SET(CMAKE_REQUIRED_LIBRARIES crypt)
CHECK_FUNCTION_EXISTS(crypt HAVE_CRYPT)
# -----------------------------------------------------------------
# check some include files exists
INCLUDE (CheckIncludeFile)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILE("sys/bitypes.h" HAVE_SYS_BITYPES_H)
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
#check sizes. Will be written to config.h
INCLUDE(CheckTypeSize)
CHECK_TYPE_SIZE(char* SIZEOF_CHAR_P)
CHECK_TYPE_SIZE(int SIZEOF_INT)
CHECK_TYPE_SIZE(long SIZEOF_LONG)
CHECK_TYPE_SIZE(short SIZEOF_SHORT)
CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T)
CHECK_TYPE_SIZE("unsigned long" SIZEOF_UNSIGNED_LONG)
FIND_PACKAGE(KDECONFIG)
FIND_PACKAGE(MSGFMT REQUIRED)
FIND_PACKAGE(MEINPROC REQUIRED)
MARK_AS_ADVANCED(KDE3_DCOPIDL2CPP_EXECUTABLE KDE3_DCOPIDL_EXECUTABLE
KDE3_KCFGC_EXECUTABLE KDE3_KDECORE_LIBRARY KDECONFIG_EXECUTABLE)
######################### Special Requirements ##########################
CHECK_INCLUDE_FILE("libofx/libofx.h" HAVE_LIBOFX_H)
IF(HAVE_LIBOFX_H)
OPTION(USE_OFX_DIRECTCONNECT "Enable to compile with ofximport support" ON)
# the USE_OFX_DIRECTCONNECT preprocessor definition will be written
# to config.h as specified in config.h.cmake
ENDIF(HAVE_LIBOFX_H)
# This is needed for QtSqlite and QtDesigner
# (they'll install files to ${QT_INSTALL_DIR}/plugins/)
GET_FILENAME_COMPONENT(QT_BIN_DIR ${QT_MOC_EXECUTABLE} PATH)
GET_FILENAME_COMPONENT(QT_DIR ${QT_BIN_DIR} PATH)
SET(QT_INSTALL_DIR ${QT_DIR} CACHE PATH
"Qt install prefix defaults to the Qt prefix: ${QT_DIR}")
# check for Sqlite and QtSqlite
FIND_PACKAGE(QtSqlite)
# check for CppUnit to build the tests
FIND_PACKAGE(CppUnit)
IF( CPPUNIT_FOUND )
SET(HAVE_LIBCPPUNIT 1)
INCLUDE_DIRECTORIES( ${CPPUNIT_INCLUDE_DIR} )
ENDIF( CPPUNIT_FOUND )
# check wether the user requests to build the test although it's not possible
IF( KDE3_BUILD_TESTS AND NOT CPPUNIT_FOUND )
message( SEND_ERROR
"CppUnit has not been found. Tests have been deactivated." )
SET( KDE3_BUILD_TESTS OFF FORCE )
ENDIF( KDE3_BUILD_TESTS AND NOT CPPUNIT_FOUND )
# do we build the tests?
IF( KDE3_BUILD_TESTS )
# INCLUDE(CTest) # (makes sense only with a ctest online dashboard)
ENABLE_TESTING()
ENDIF( KDE3_BUILD_TESTS )
INCLUDE(KMyMoneyMacros)
######################### Settings ##########################
# If no build type is set, use "Release with Debug Info"
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
ENDIF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build.
Possible values are: 'Release' 'RelWithDebInfo' 'Debug' 'Debugfull' 'Profile'
The default value is: 'RelWithDebInfo'" FORCE)
ADD_DEFINITIONS(${QT_DEFINITIONS} ${KDE3_DEFINITIONS})
# tell the KMyMoney sources that a config.h is present:
ADD_DEFINITIONS( -DHAVE_CONFIG_H )
# preprocessor definitions in case this is a debug build
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER)
IF(${CMAKE_BUILD_TYPE_TOLOWER} MATCHES "^debug(full)?$|^profile$")
ADD_DEFINITIONS( -DKMM_DEBUG )
ENDIF()
# tells gcc to enable exception handling
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
# use position independent code
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
# be more pedantic about common symbols
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
# Debug, Debugfull, Profile
SET(CMAKE_CXX_FLAGS_DEBUG
"-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
SET(CMAKE_CXX_FLAGS_DEBUGFULL
"-g3 -fno-inline")
SET(CMAKE_CXX_FLAGS_PROFILE
"-g3 -fno-inline -ftest-coverage -fprofile-arcs")
# be pedantic about undefined symbols when linking shared libraries
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
OPTION(USE_LEAK_CHECK "Enable to compile with memory leak check support (deprecated)" OFF)
if(USE_LEAK_CHECK)
message("Warning: Leak check support is activated but deprecated. Better use valgrind.")
ADD_DEFINITIONS( -D_CHECK_MEMORY )
endif(USE_LEAK_CHECK)
OPTION(USE_QT_DESIGNER
"Install KMyMoney specific widget library for Qt-Designer (default=OFF)" OFF)
# initialize the default install prefix to the kde3 prefix
# ( usually /opt/kde3. ${KDE3PREFIX} is set by FIND_PACKAGE(KDE3) above )
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${KDE3PREFIX}" CACHE PATH
"KMyMoney2 install prefix defaults
to the KDE3 install prefix: ${KDE3PREFIX}" FORCE)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# the RPATH to be used when installing
# (cf. http://www.vtk.org/Wiki/CMake_RPATH_handling)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(MAN_INSTALL_DIR "/usr/share/man" CACHE PATH "Install path for manpages")
# remark: these directories are used to find libs and .h files.
# they are set globally after this point. no need to add everywhere.
LINK_DIRECTORIES( ${KDE3_LIB_DIR} )
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${KDE3_INCLUDE_DIR}
${QT_INCLUDE_DIR}
${PKGS_INCLUDE_DIRS})
######################### The Actual Targets ##########################
ADD_SUBDIRECTORY( libkgpgfile )
ADD_SUBDIRECTORY( libkdchart )
ADD_SUBDIRECTORY( kmymoney2 )
ADD_SUBDIRECTORY( po )
ADD_SUBDIRECTORY( doc )
ADD_SUBDIRECTORY( developer-doc )
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# This command will extract and merge the translations.
# Note that this will modify the source tree.
ADD_CUSTOM_TARGET(messages
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/admin/extract-messages.sh" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
######################### Package Generation ##########################
##### General Setup (tar.gz / tar.bz2 source and binary) #####
# by default, the package name is kmymoney
SET(CPACK_PACKAGE_NAME "kmymoney")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Personal Finance Manager")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "/opt/kde3")
# When building with 'make package', use these cpack generators
SET(CPACK_GENERATOR "TGZ" "TBZ2")
# When building with 'make package_source', use these cpack generators
SET(CPACK_SOURCE_GENERATOR "TGZ" "TBZ2")
# don't include files matching these into the source packages
# (Note: all other files in the source directory will be included)
SET(CPACK_SOURCE_IGNORE_FILES
"${CMAKE_CURRENT_BINARY_DIR}" # the build directory. MUST build out-of-source!
"/CVS/" # cvs directories
"/\\\\." # all files starting with '.' (this includes .cvsignore files)
"~$" # all files ending in '~'
"\\\\.m4$" # since this is a cmake dist, we remove automake files
"\\\\.m4\\\\.in$" "\\\\.am$" "Makefile\\\\.dist" "configure\\\\.in"
)
# This will create the cpack configuration files.
INCLUDE(CPack)
##### RPM Setup (.rpm and .srpm) #####
# We use cmake/modules/UseRPMTools.cmake for RPM creation
INCLUDE(UseRPMTools)
IF(RPMTools_FOUND)
SET(RPM_VERSION_SUFFIX ${VERSION_SUFFIX})
# kmymoney conflicts with kmymoney-unstable
SET(RPM_CONFLICTING kmymoney-unstable)
RPMTools_ADD_RPM_TARGETS(kmymoney kmymoney.spec.in)
# kmymoney-unstable conflicts with kmymoney
SET(RPM_CONFLICTING kmymoney)
RPMTools_ADD_RPM_TARGETS(kmymoney-unstable kmymoney.spec.in)
ENDIF(RPMTools_FOUND)
######################### Output Results #############################
# create the config.h file out of the config.h.cmake
CONFIGURE_FILE (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
# this macro maps the boolean variable ${_varname} to "yes"/"no"
# and writes the output to the variable nice_${_varname}
MACRO(nice_yesno _varname)
if(${${_varname}})
SET("nice_${_varname}" "yes")
else(${${_varname}})
if(${_varname})
SET("nice_${_varname}" "yes")
else(${_varname})
SET("nice_${_varname}" "no")
endif(${_varname})
endif(${${_varname}})
ENDMACRO(nice_yesno _varname)
nice_yesno("HAVE_LIBOFX_H")
nice_yesno("USE_OFX_DIRECTCONNECT")
nice_yesno("QT_SQLITE_FOUND")
nice_yesno("USE_LEAK_CHECK")
nice_yesno("USE_QT_DESIGNER")
nice_yesno("HAVE_LIBCPPUNIT")
nice_yesno("KDE3_BUILD_TESTS")
message("
-------- KMyMoney ${CPACK_PACKAGE_VERSION}-${VERSION_SUFFIX} --------
Configure results (user options):
--------------------------------------------
OFX plugin: ${nice_HAVE_LIBOFX_H}
OFX direct connect: ${nice_USE_OFX_DIRECTCONNECT}
SQLITE3 support: ${nice_QT_SQLITE_FOUND}
--------------------------------------------
Configure results (developer options):
--------------------------------------------
Qt-Designer library support: ${nice_USE_QT_DESIGNER}
PDF document generation: ?
CPPUNIT support: ${nice_HAVE_LIBCPPUNIT}
build tests: ${nice_KDE3_BUILD_TESTS}
Build type: ${CMAKE_BUILD_TYPE}")
if(USE_LEAK_CHECK)
message("
Memory leak check support (deprecated): ${nice_USE_LEAK_CHECK}")
endif(USE_LEAK_CHECK)
message("--------------------------------------------
")
# Display this message the first time only.
if(QT_SQLITE_FALLBACK AND QT_SQLITE_FOUND AND NOT Sqlite_FIND_QUIETLY)
message("Note: You should run 'make install-qsqlite3' to enable Sqlite3 support.
")
endif(QT_SQLITE_FALLBACK AND QT_SQLITE_FOUND AND NOT Sqlite_FIND_QUIETLY)
message("Good - your configure finished.
Now type 'make' to build KMyMoney. For more help, consult README.cmake
")