forked from KDAB/GammaRay
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
437 lines (380 loc) · 14.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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# This is the top-level CMakeLists.txt file for the GammaRay project.
#
# Pass the following variables to cmake to control the build:
#
# -DGAMMARAY_UNKNOWN_CXX_MANGLED_NAMES=[on|off]
# Set this if your compiler uses an unsupported C++ name mangling scheme
# Default=off
#
# To build the man page from POD, run 'make man' after CMake.
# To install the resulting man page, run 'make install'
#
project(GammaRay)
cmake_minimum_required(VERSION 2.8)
if(NOT Prog_NAME)
set(Prog_NAME "GammaRay")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH})
set(GAMMARAY_VERSION_MAJOR "1")
set(GAMMARAY_VERSION_MINOR "1")
set(GAMMARAY_VERSION_PATCH "50")
set(GAMMARAY_VERSION "${GAMMARAY_VERSION_MAJOR}.${GAMMARAY_VERSION_MINOR}.${GAMMARAY_VERSION_PATCH}")
set(GAMMARAY_VERSION_STRING "${GAMMARAY_VERSION}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
enable_testing()
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE _git_revision)
string(REGEX REPLACE "\n" "" _git_revision "${_git_revision}")
set(GAMMARAY_VERSION_STRING "${GAMMARAY_VERSION_STRING} (revision: ${_git_revision})")
endif()
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
message(STATUS "Building ${Prog_NAME} ${GAMMARAY_VERSION_STRING} in ${CMAKE_BUILD_TYPE} mode")
add_definitions(-DPROGRAM_NAME=\"${Prog_NAME}\")
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
include(GammaRayMacros)
include(MacroLogFeature)
set(QT_MIN_VERSION "4.7.0")
find_package(Qt5Transitional REQUIRED
Core
Gui
Script
ScriptTools
Svg
Test
)
# TODO: Remove me once fixed in ECM module
if(Qt5Core_FOUND)
# Avoid errors and build in PIC mode:
# qt5/qtbase/include/QtCore/qglobal.h:1765:4: error:
# #error "You must build your code with position independent code if Qt was
# built with -reduce-relocations. " "Compile your code with -fPIC or -fPIE."
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
if(CMAKE_BUILD_TYPE MATCHES "^[Rr]elease$")
add_definitions(-DQT_NO_DEBUG_OUTPUT)
endif()
include_directories(
${QT_INCLUDES}
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}
# TODO: These paths should be removed so we can be sure plugins don't include non-public headers
${CMAKE_SOURCE_DIR}/core
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/3rdparty
${CMAKE_SOURCE_DIR}/3rdparty/kde
)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
set(PLUGIN_INSTALL_DIR "${LIB_INSTALL_DIR}/qt4/plugins")
set(
INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Devel
)
find_path(QT_PRIVATE_INCLUDE_DIR private/qobject_p.h PATHS ${QT_INCLUDES})
if(QT_PRIVATE_INCLUDE_DIR)
# not enough, some of them include harfbuzz headers, so we need to find those as well
# for now we assume a regular Qt4 source build layout, but that probably should be generalized
find_path(HARFBUZZ_INCLUDE_DIR harfbuzz.h PATH ${QT_PRIVATE_INCLUDE_DIR}/../../src/3rdparty/harfbuzz/src)
endif()
if(QT_PRIVATE_INCLUDE_DIR AND HARFBUZZ_INCLUDE_DIR)
set(HAVE_PRIVATE_QT_HEADERS TRUE)
include_directories(${HARFBUZZ_INCLUDE_DIR})
else()
set(HAVE_PRIVATE_QT_HEADERS FALSE)
# needs to go before Qt includes, in case we have non-working headers with the same name there
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/3rdparty/qt)
endif()
macro_log_feature(HAVE_PRIVATE_QT_HEADERS "Qt internals" "Private Qt headers, necessary for painter debugging/profiling." "http://developer.qt.nokia.com/" FALSE ${QT_MIN_VERSION} "You must have a build version of Qt available and the qmake found first in your execute path must be from this build.")
if(WIN32 OR APPLE)
set(BUILD_TIMER_PLUGIN TRUE)
else()
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
macro_log_feature(HAVE_CLOCK_GETTIME "librt" "High resolution clock for the timer profiler plugin." "part of glibc" FALSE)
set(BUILD_TIMER_PLUGIN ${HAVE_CLOCK_GETTIME})
endif()
if(WIN32)
add_definitions(-DUNICODE -D_UNICODE)
endif()
if(APPLE)
# on the Mac support an extra install directory for application bundles
set(
INSTALL_TARGETS_DEFAULT_ARGS
${INSTALL_TARGETS_DEFAULT_ARGS}
BUNDLE DESTINATION "/Applications/Qt4"
)
endif()
if(UNIX AND NOT APPLE)
set(DOC_INSTALL_DIR share/doc/gammaray/)
else()
set(DOC_INSTALL_DIR .)
endif()
# TODO: find a nicer way for all this. ideally auto-detect the name mangling
# format, but at least guess a default based on OS + compiler.
option(
GAMMARAY_UNKNOWN_CXX_MANGLED_NAMES
"Enable if your compiler uses an unsupported C++ name mangling scheme"
OFF
)
if(GAMMARAY_UNKNOWN_CXX_MANGLED_NAMES)
add_definitions(-DGAMMARAY_UNKNOWN_CXX_MANGLED_NAMES)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-gammaray.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-gammaray.h
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-gammaray-version.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-gammaray-version.h
)
if(CMAKE_COMPILER_IS_GNUCXX)
check_cxx_compiler_flag(-Wunused-but-set-variable HAVE_GCC_UNUSED_BUT_SET)
check_cxx_compiler_flag(-Wlogical-op HAVE_GCC_LOGICAL_OP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wextra -Woverloaded-virtual -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wmissing-noreturn -Werror=return-type")
if(HAVE_GCC_UNUSED_BUT_SET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable")
endif()
if(HAVE_GCC_LOGICAL_OP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
endif()
endif()
if(MINGW)
# mingw will error out on the crazy casts in probe.cpp without this
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif()
# linker flags
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
endif()
endif()
add_subdirectory(injector)
add_subdirectory(launcher)
find_package(Graphviz)
macro_log_feature(GRAPHVIZ_FOUND "Graphviz" "Graph layouting library for the state machine visualizer." "http://www.graphviz.org/" FALSE)
find_package(VTK)
macro_log_feature(VTK_FOUND "VTK" "Graph visualizing library for the object visualization plugin." "http://www.vtk.org" FALSE)
set(gammaray_srcs
3rdparty/kde/krecursivefilterproxymodel.cpp
3rdparty/kde/kfilterproxysearchline.cpp
3rdparty/qt/resourcemodel.cpp
# FIXME: Remove me
include/util.cpp
core/mainwindow.cpp
core/metaobject.cpp
core/metaobjectrepository.cpp
core/metaproperty.cpp
core/metapropertymodel.cpp
core/pluginmanager.cpp
core/probe.cpp
core/proxydetacher.cpp
core/objectlistmodel.cpp
core/objectpropertymodel.cpp
core/objectdynamicpropertymodel.cpp
core/objectstaticpropertymodel.cpp
core/objectclassinfomodel.cpp
core/objectmethodmodel.cpp
core/objectenummodel.cpp
core/objecttreemodel.cpp
core/connectionmodel.cpp
core/connectionfilterproxymodel.cpp
core/methodinvocationdialog.cpp
core/methodargumentmodel.cpp
core/multisignalmapper.cpp
core/toolmodel.cpp
core/proxydetacher.cpp
core/proxytoolfactory.cpp
core/sidepane.cpp
core/palettemodel.cpp
core/propertywidget.cpp
propertyeditor/propertycoloreditor.cpp
propertyeditor/propertydoublepaireditor.cpp
propertyeditor/propertyeditorfactory.cpp
propertyeditor/propertyextendededitor.cpp
propertyeditor/propertyfonteditor.cpp
propertyeditor/propertyintpaireditor.cpp
propertyeditor/propertypaletteeditor.cpp
propertyeditor/palettedialog.cpp
tools/modelinspector/modeltester.cpp
tools/modelinspector/modelmodel.cpp
tools/modelinspector/modelcellmodel.cpp
tools/sceneinspector/graphicsview.cpp
tools/sceneinspector/graphicssceneview.cpp
tools/sceneinspector/scenemodel.cpp
tools/metatypebrowser/metatypesmodel.cpp
tools/fontbrowser/fontmodel.cpp
tools/localeinspector/localemodel.cpp
tools/localeinspector/localedataaccessor.cpp
tools/localeinspector/localeaccessormodel.cpp
tools/codecbrowser/codecmodel.cpp
tools/textdocumentinspector/textdocumentmodel.cpp
tools/textdocumentinspector/textdocumentformatmodel.cpp
tools/textdocumentinspector/textdocumentcontentview.cpp
tools/messagehandler/messagehandler.cpp
tools/messagehandler/messagemodel.cpp
tools/codecbrowser/codecbrowser.cpp
tools/connectioninspector/connectioninspector.cpp
tools/fontbrowser/fontbrowser.cpp
tools/localeinspector/localeinspector.cpp
tools/metatypebrowser/metatypebrowser.cpp
tools/modelinspector/modelinspector.cpp
tools/modelinspector/modelinspectorwidget.cpp
tools/objectinspector/objectinspector.cpp
tools/resourcebrowser/resourcebrowser.cpp
tools/resourcebrowser/resourcefiltermodel.cpp
tools/sceneinspector/sceneinspector.cpp
tools/selectionmodelinspector/selectionmodelinspector.cpp
tools/textdocumentinspector/textdocumentinspector.cpp
tools/widgetinspector/widgetinspector.cpp
tools/widgetinspector/overlaywidget.cpp
tools/widgetinspector/widgettreemodel.cpp
tools/widgetinspector/widgetpreviewwidget.cpp
tools/styleinspector/styleinspector.cpp
tools/styleinspector/pixelmetricmodel.cpp
tools/styleinspector/standardiconmodel.cpp
tools/styleinspector/primitivemodel.cpp
tools/styleinspector/controlmodel.cpp
tools/styleinspector/styleoption.cpp
tools/styleinspector/abstractstyleelementmodel.cpp
tools/styleinspector/abstractstyleelementstatetable.cpp
tools/styleinspector/styleelementstatetablepage.cpp
tools/styleinspector/complexcontrolmodel.cpp
tools/styleinspector/dynamicproxystyle.cpp
hooking/abstractfunctionoverwriter.cpp
hooking/functionoverwriterfactory.cpp
hooking/winfunctionoverwriter.cpp
hooking/unixfunctionoverwriter.cpp
)
if(HAVE_PRIVATE_QT_HEADERS)
set(gammaray_srcs
${gammaray_srcs}
core/paintbuffermodel.cpp
core/paintbufferviewer.cpp
core/paintbufferreplaywidget.cpp
)
endif()
if(BUILD_TIMER_PLUGIN)
set(gammaray_srcs
${gammaray_srcs}
tools/timertop/timertop.cpp
tools/timertop/timermodel.cpp
tools/timertop/timerinfo.cpp
tools/timertop/functioncalltimer.cpp
)
endif()
if(NOT WIN32)
set(gammaray_srcs ${gammaray_srcs} tools/messagehandler/backtrace_unix.cpp)
elseif(MINGW)
set(gammaray_srcs ${gammaray_srcs} tools/messagehandler/backtrace_dummy.cpp)
else()
set(gammaray_srcs ${gammaray_srcs}
tools/messagehandler/backtrace_win.cpp
tools/messagehandler/StackWalker.cpp)
endif()
qt4_automoc(${gammaray_srcs})
qt4_wrap_ui(gammaray_srcs
core/mainwindow.ui
core/propertywidget.ui
core/methodinvocationdialog.ui
core/paintbufferviewer.ui
propertyeditor/propertydoublepaireditor.ui
propertyeditor/propertyextendededitor.ui
propertyeditor/propertyintpaireditor.ui
propertyeditor/palettedialog.ui
tools/sceneinspector/graphicssceneview.ui
tools/codecbrowser/codecbrowser.ui
tools/connectioninspector/connectioninspector.ui
tools/fontbrowser/fontbrowser.ui
tools/localeinspector/localeinspector.ui
tools/messagehandler/messagehandler.ui
tools/metatypebrowser/metatypebrowser.ui
tools/modelinspector/modelinspectorwidget.ui
tools/objectinspector/objectinspector.ui
tools/resourcebrowser/resourcebrowser.ui
tools/sceneinspector/sceneinspector.ui
tools/selectionmodelinspector/selectionmodelinspector.ui
tools/styleinspector/styleinspector.ui
tools/textdocumentinspector/textdocumentinspector.ui
tools/widgetinspector/widgetinspector.ui
tools/styleinspector/styleelementstatetablepage.ui
)
if(BUILD_TIMER_PLUGIN)
qt4_wrap_ui(gammaray_srcs
tools/timertop/timertop.ui
)
endif()
qt4_add_resources(gammaray_srcs resources/gammaray.qrc)
add_library(gammaray_probe
SHARED ${gammaray_srcs}
)
if(BUILD_TIMER_PLUGIN AND NOT WIN32 AND NOT APPLE)
target_link_libraries(gammaray_probe rt)
endif()
target_link_libraries(gammaray_probe
${QT_QTCORE_LIBRARIES}
${QT_QTGUI_LIBRARIES}
)
if(NOT WIN32)
target_link_libraries(gammaray_probe dl)
endif()
set_target_properties(gammaray_probe PROPERTIES PREFIX "")
install(TARGETS gammaray_probe ${INSTALL_TARGETS_DEFAULT_ARGS})
if(UNIX AND NOT APPLE)
set(XDG_APPS_INSTALL_DIR share/applications)
install(FILES GammaRay.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES resources/GammaRay-16x16.png DESTINATION share/icons/hicolor/16x16/apps RENAME GammaRay.png)
install(FILES resources/GammaRay-32x32.png DESTINATION share/icons/hicolor/32x32/apps RENAME GammaRay.png)
install(FILES resources/GammaRay-48x48.png DESTINATION share/icons/hicolor/48x48/apps RENAME GammaRay.png)
install(FILES resources/GammaRay-128x128.png DESTINATION share/icons/hicolor/128x128/apps RENAME GammaRay.png)
install(FILES resources/GammaRay-256x256.png DESTINATION share/icons/hicolor/256x256/apps RENAME GammaRay.png)
install(FILES resources/GammaRay-512x512.png DESTINATION share/icons/hicolor/512x512/apps RENAME GammaRay.png)
endif()
set(LICENSE_FILE "License.txt")
set(README_FILE "ReadMe.txt")
if(NOT APPLE)
install(FILES "${LICENSE_FILE}" "${README_FILE}" DESTINATION ${DOC_INSTALL_DIR})
endif()
find_program(CPPCHECK_EXECUTABLE cppcheck)
if(CPPCHECK_EXECUTABLE)
set(_cppcheck_flags "-I${CMAKE_CURRENT_BINARY_DIR}")
get_directory_property(_inc_dirs INCLUDE_DIRECTORIES)
foreach(_current ${_inc_dirs})
set(_cppcheck_flags ${_cppcheck_flags} "-I${_current}")
endforeach()
get_directory_property(_defs COMPILE_DEFINITIONS)
foreach(_current ${_defs})
set(_cppcheck_flags ${_cppcheck_flags} "-D${_current}")
endforeach()
add_custom_target(cppcheck
COMMAND ${CPPCHECK_EXECUTABLE} --enable=all -j 4 --suppress=*:${QT_INCLUDE_DIR}* ${_cppcheck_flags}
-i${CMAKE_CURRENT_SOURCE_DIR}/3rdparty
-i${CMAKE_CURRENT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running the cppcheck static code checker"
)
endif()
if(UNIX)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/gammaray.1
COMMAND pod2man -c "KDAB Products" -r "\"${GAMMARAY_VERSION}\"" -s 1 ${CMAKE_SOURCE_DIR}/gammaray.pod ${CMAKE_BINARY_DIR}/gammaray.1
DEPENDS ${CMAKE_SOURCE_DIR}/gammaray.pod
)
add_custom_target(man ALL DEPENDS ${CMAKE_BINARY_DIR}/gammaray.1)
install(FILES ${CMAKE_BINARY_DIR}/gammaray.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
endif()
include(ExternalProject)
add_subdirectory(include)
add_subdirectory(tests)
add_subdirectory(tools)
macro_display_feature_log()