summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: d7ac656378f5dcb875c969d71d91833373b02ca1 (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
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
PROJECT(kbfx)

CMAKE_MINIMUM_REQUIRED(VERSION 2.4.2 FATAL_ERROR)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmakemodules)
SET(CMAKE_COLOR_MAKEFILE ON CACHE STRING "Enable/Disable color output during build." FORCE)
#SET(CMAKE_VERBOSE_MAKEFILE OFF CACHE STRING "Enable/Disable cmake debug output during build." FORCE)

# Optimization flags
# SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3")
# SET(CMAKE_C_FLAGS_DISTRIBUTION "-O3")

# Global variable CMAKE_BUILD_TYPE
# None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used)
# Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG)
# Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE)
# RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO
# MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL)
IF (NOT CMAKE_BUILD_TYPE)
	SET(CMAKE_BUILD_TYPE RelWithDebInfo
	    CACHE
	    STRING "Specify build type: None Debug Release RelWithDebInfo MinSizeRel."
	    FORCE)
ENDIF (NOT CMAKE_BUILD_TYPE)

OPTION(USE_STRIGI "Enable use of Strigi search support (disabled)" OFF)
OPTION(USE_MENUDRAKE "Use 'menudrake' instead of 'kmenuedit' in Mandriva (auto)" ON)
OPTION(USE_KDE4 "Compile for KDE4 (disabled)" OFF)

SET(BIN_SEARCH_PATHES
    $ENV{HOME}/bin
    $ENV{HOME}/usr/bin
    $ENV{KDEDIR}/bin
    ${CMAKE_INSTALL_PREFIX}/bin
    /opt/kde/bin
    /opt/kde3/bin
    /opt/kde4/bin
    /usr/kde/3.5/bin
    /usr/bin
    /usr/local/bin
    /opt/bin
    )
SET(INCLUDE_SEARCH_PATHES
  $ENV{HOME}/include
  $ENV{HOME}/usr/include
  $ENV{KDEDIR}/include
  /opt/kde/include
  /opt/kde3/include
  /opt/kde4/include
  /usr/kde/3.5/include
  /usr/include
  /usr/local/include
  /opt/include
  ${CMAKE_SYSTEM_INCLUDE_PATH}
  )
SET(LIB_SEARCH_PATHES
  $ENV{HOME}/lib
  $ENV{HOME}/usr/lib
  $ENV{KDEDIR}/lib
  /opt/kde/lib
  /opt/kde3/lib
  /opt/kde4/lib
  /usr/kde/3.5/lib
  /usr/lib
  /usr/local/lib
  /opt/lib
  )

# Setting versions

# For versions that are stable set to 1, else to 0
SET(APPLICATION_STABLE 1)

SET(LIB_MAJOR 4)
SET(LIB_MINOR 9)
SET(LIB_RELEASE 3)
SET(LIB_SUB_RELEASE 1)
SET(APPLICATION_INTERNAL_VERSION "20070516")
SET(APPLICATION_DATE "2007-05-16")

SET(APPLICATION_NAME "${PROJECT_NAME}")
SET(APPLICATION_MAIN_VERSION "0.${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE}")

IF (APPLICATION_STABLE)
	SET(APPLICATION_STABLE_RELEASE ".${LIB_SUB_RELEASE}")
	SET(APPLICATION_VERSION "${APPLICATION_MAIN_VERSION}.${LIB_SUB_RELEASE}")
	SET(GENTOO_VERSION "${APPLICATION_MAIN_VERSION}.${LIB_SUB_RELEASE}")
ELSE (APPLICATION_APPLICATION_STABLE "")
	SET(STABLE_RELEASE)
	SET(APPLICATION_VERSION "${APPLICATION_MAIN_VERSION}-${LIB_SUB_RELEASE}")
	SET(GENTOO_VERSION "${APPLICATION_MAIN_VERSION}_pre${LIB_SUB_RELEASE}")
ENDIF (APPLICATION_STABLE)

SET(VERSION ${APPLICATION_VERSION})

SET(STRIGI_VERSION "0.3.11")
SET(GENTOO_KEYWORDS "x86 ~ppc ~amd64")

# Prepare docbook part
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/doc/en/index.docbook.in ${CMAKE_BINARY_DIR}/doc/en/index.docbook @ONLY)

IF (USE_STRIGI)
	FIND_PACKAGE(Strigi REQUIRED)
	INCLUDE_DIRECTORIES(${STRIGI_INCLUDE_DIR})
	MESSAGE(STATUS "Strigi support is: ON!")
ELSE (USE_STRIGI)
	MESSAGE(STATUS "Strigi support is: OFF!")
ENDIF (USE_STRIGI)


FIND_PROGRAM(HAVE_MANDRAKE menudrake)
IF (HAVE_MANDRAKE AND USE_MENUDRAKE)
	SET(MANDRAKE "1")
	MESSAGE(STATUS "Will use 'menudrake' instead of 'kmenuedit'!")
ELSE (HAVE_MANDRAKE AND USE_MENUDRAKE)
	SET(MANDRAKE "")
	MESSAGE(STATUS "Will use 'kmenuedit'!")
ENDIF (HAVE_MANDRAKE AND USE_MENUDRAKE)

IF (NOT USE_KDE4)
	MESSAGE(STATUS "Building for KDE3")
	INCLUDE(TestCXXAcceptsFlag)

	SET(CMAKE_CXX_FLAGS_DEBUG
	"${CMAKE_CXX_FLAGS_DEBUG} -DTESTING_RC=\"\\\"\${CMAKE_SOURCE_DIR}/configdialog/kbfxconfigappui.rc\\\"\"")

	CHECK_CXX_ACCEPTS_FLAG("-fexceptions" CXX_EXCEPTION)
	CHECK_CXX_ACCEPTS_FLAG("-fstack-protector" CXX_PROTECTOR)

	FIND_PACKAGE(KDE3 REQUIRED)

	INCLUDE(FindKdeLibs)
	INCLUDE(MacroEnsureVersion)

	# Dummy macros for compatibility
	MACRO(KDE4_AUTOMOC _dummy)
	ENDMACRO(KDE4_AUTOMOC)

	MACRO(KDE4_ADD_LIBRARY _dummy _dummy1 _dummy2)
	ENDMACRO(KDE4_ADD_LIBRARY)

	MACRO(KDE4_INSTALL_LIBTOOL_FILE _dummy _dummy1)
	ENDMACRO(KDE4_INSTALL_LIBTOOL_FILE)

	MACRO(KDE4_ADD_UI3_FILES _dummy _dummy1)
	ENDMACRO(KDE4_ADD_UI3_FILES)

	MACRO(KDE4_ADD_DCOP_SKELS _dummy _dummy1)
	ENDMACRO(KDE4_ADD_DCOP_SKELS)

	MACRO(KDE4_ADD_EXECUTABLE _dummy _dummy1)
	ENDMACRO(KDE4_ADD_EXECUTABLE)

	MACRO(KDE4_INSTALL_ICONS _dummy)
	ENDMACRO(KDE4_INSTALL_ICONS)
ELSE (NOT USE_KDE4)
	MESSAGE(STATUS "Building for KDE4")
	FIND_PACKAGE(KDE4 REQUIRED)
	ADD_DEFINITIONS(${KDE4_DEFINITIONS} ${QT_DEFINITIONS})
	SET(INCLUDE_SEARCH_PATHES
	    ${INCLUDE_SEARCH_PATHES}
	    ${KDE4_INCLUDES}
	    )
	SET(LIB_SEARCH_PATHES
	    ${LIB_SEARCH_PATHES}
	    ${KDE4_LIB_DIR}
	    )
ENDIF (NOT USE_KDE4)

IF (NOT QT_FOUND)
    MESSAGE("TQt3 not found, assuming TQt4 was desired")
    SET(TQT_INCLUDE_DIR "/usr/include/qt4")
ELSE ()
    SET(TQT_INCLUDE_DIR "${QT_INCLUDE_DIR}")
ENDIF ()

INCLUDE_DIRECTORIES(
    ${CMAKE_BINARY_DIR}
    ${CMAKE_BINARY_DIR}/kbfxlib/data
    ${CMAKE_BINARY_DIR}/kbfxlib/common
    ${CMAKE_BINARY_DIR}/src
    ${CMAKE_BINARY_DIR}/configdialog
    ${CMAKE_BINARY_DIR}/plugins/common
    ${CMAKE_SOURCE_DIR}
    ${CMAKE_SOURCE_DIR}/kbfxlib/data
    ${CMAKE_SOURCE_DIR}/kbfxlib/common
    ${CMAKE_SOURCE_DIR}/src
    ${CMAKE_SOURCE_DIR}/configdialog
    ${CMAKE_SOURCE_DIR}/plugins/common
    ${TQT_INCLUDE_DIR}
    ${KDE3_INCLUDE_DIR}
    ${KDE3_INCLUDE_DIR}/kbfx
    ${KDE3_INCLUDE_DIR}/kbfx/plugins
    ${INCLUDE_SEARCH_PATHES}
    )

IF (NOT USE_KDE4)
	IF (CXX_EXCEPTION)
	    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
	ENDIF (CXX_EXCEPTION)
	IF (CXX_PROTECTOR)
	    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
	ENDIF (CXX_PROTECTOR)

	ADD_DEFINITIONS(${KDE3_DEFINITIONS} ${QT_DEFINITIONS})
	SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
	SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

	IF(KDE3_KDECONFIG_EXECUTABLE)
	    EXECUTE_PROCESS(COMMAND ${KDE3_KDECONFIG_EXECUTABLE} "--version" OUTPUT_VARIABLE output)
	    STRING(REGEX MATCH "KDE: [0-9]+\\.[0-9]+\\.[0-9]+" KDEVERSION "${output}")
	    STRING(REGEX REPLACE "^KDE: " "" KDEVERSION "${KDEVERSION}")
	ENDIF(KDE3_KDECONFIG_EXECUTABLE)
	SET(KDE_MIN_VERSION "3.5.0")
	MACRO_ENSURE_VERSION(${KDE_MIN_VERSION} ${KDEVERSION} VERSION_OK)
	IF(NOT VERSION_OK)
	    MESSAGE(FATAL_ERROR "You need at least KDE Version of 3.5.0 in order to compile KBFX.\n   Please upgrade your KDE or install the development files of KDE.")
	ENDIF(NOT VERSION_OK)
ENDIF (NOT USE_KDE4)

SET(KBFX_LIB_INSTALL_DIR ${LIB_INSTALL_DIR})

SET(QT_UIC_EXECUTABLE "/usr/bin/uic-tqt")
SET(QT_MOC_EXECUTABLE "/usr/bin/tmoc")

SET(CMAKE_CXX_FLAGS "-I/usr/include/tqt -include tqt.h -DTQT_THREAD_SUPPORT")

ADD_SUBDIRECTORY(kbfxlib/data)
ADD_SUBDIRECTORY(kbfxlib/common)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(configdialog)
ADD_SUBDIRECTORY(skin/vector)
ADD_SUBDIRECTORY(skin/raster/default)
ADD_SUBDIRECTORY(skin/raster/2panels)
ADD_SUBDIRECTORY(images)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(doc/en)
ADD_SUBDIRECTORY(doc/common)
ADD_SUBDIRECTORY(po)
ADD_SUBDIRECTORY(plugins/common)
ADD_SUBDIRECTORY(plugins/applications)
ADD_SUBDIRECTORY(plugins/settings)
ADD_SUBDIRECTORY(plugins/plasmoids)
ADD_SUBDIRECTORY(plugins/recentstuff)
IF (USE_STRIGI)
	ADD_SUBDIRECTORY(plugins/strigi)
ENDIF (USE_STRIGI)

CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/kbfx.spec.in ${CMAKE_BINARY_DIR}/kbfx.spec @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/kbfx.ebuild.in ${CMAKE_BINARY_DIR}/kbfx-${GENTOO_VERSION}.ebuild @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/strigi.ebuild.in ${CMAKE_BINARY_DIR}/strigi-${STRIGI_VERSION}.ebuild @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/kbfx-svn.ebuild.in ${CMAKE_BINARY_DIR}/kbfx-9999.ebuild @ONLY)

SET(DIST_INCLUDE "kbfx-9999.ebuild kbfx.spec kbfx-${GENTOO_VERSION}.ebuild strigi-${STRIGI_VERSION}.ebuild")
SET(DIST_EXCLUDE "Helperstuff")
CONFIGURE_FILE(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmakemodules/makedist.sh.in"
    "${CMAKE_CURRENT_BINARY_DIR}/makedist.sh"
    IMMEDIATE
    @ONLY)
ADD_CUSTOM_TARGET(dist
    "${CMAKE_BINARY_DIR}/makedist.sh"
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

IF (NOT USE_KDE4)
	CONFIGURE_FILE(
	    "${CMAKE_CURRENT_SOURCE_DIR}/cmakemodules/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")
ENDIF (NOT USE_KDE4)


FILE(GLOB _POFILES po/*.po)
FOREACH(_p ${_POFILES})
  SET(POFILES "${_p} ${POFILES}")
ENDFOREACH(_p)

SET(MESSAGES_DIR ${CMAKE_SOURCE_DIR})
CONFIGURE_FILE(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmakemodules/package_messages.sh.in"
    "${CMAKE_CURRENT_BINARY_DIR}/package_messages.sh"
    IMMEDIATE
    @ONLY)
ADD_CUSTOM_TARGET(package-messages
    "${CMAKE_CURRENT_BINARY_DIR}/package_messages.sh")