forked from KDAB/GammaRay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
640 lines (573 loc) · 22.5 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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
# This is the top-level CMakeLists.txt file for the GammaRay project.
#
# Pass the following variables to cmake to control the build:
# (See Install.txt for more information)
#
# -DGAMMARAY_ENFORCE_QT4_BUILD=[true|false]
# Force building against Qt4, even if Qt5 is found.
# Default=false
#
# -DGAMMARAY_BUILD_UI=[true|false]
# Build the client and in-process UI.
# Default=true
#
# -DGAMMARAY_PROBE_ONLY_BUILD=[true|false]
# Build only an additional probe configuration for an already existing launcher.
# Default=false
#
# -DGAMMARAY_UNKNOWN_CXX_MANGLED_NAMES=[true|false]
# Enable if your compiler uses an unsupported C++ name mangling scheme.
# Default=false
#
# To build the man page from POD, run 'make man' after CMake (assumes perl is available)
# To install the resulting man page, run 'make install'
# Not available on Windows.
#
# To build the apidox, run 'make docs' after CMake (assumes doxygen is available)
#
project(GammaRay)
cmake_minimum_required(VERSION 2.8.11)
cmake_policy(SET CMP0020 NEW)
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH})
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MACOSX_RPATH TRUE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
include(CheckCXXCompilerFlag)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(GammaRayMacros)
include(GammaRayMacrosInternal)
include(FeatureSummary)
include(ECMGeneratePriFile)
# Exit for blacklisted compilers (those that don't support C++11 very well)
# MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
# Clang 3.0
set(BAD_CXX_MESSAGE "")
if(MSVC)
if(MSVC_VERSION LESS 1500)
set(BAD_CXX_MESSAGE "MSVC 2008 or higher")
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1.0)
set(BAD_CXX_MESSAGE "Clang v3.1.0 or higher")
endif()
endif()
if(BAD_CXX_MESSAGE)
message(FATAL_ERROR "\nSorry, ${BAD_CXX_MESSAGE} is required to build this software. Please retry using a modern compiler that supports C++11 lambdas.")
endif()
# Enable the test harness
enable_testing()
# Version setup
set(GAMMARAY_VERSION_MAJOR "2")
set(GAMMARAY_VERSION_MINOR "2")
set(GAMMARAY_VERSION_PATCH "50")
set(GAMMARAY_VERSION "${GAMMARAY_VERSION_MAJOR}.${GAMMARAY_VERSION_MINOR}.${GAMMARAY_VERSION_PATCH}")
set(GAMMARAY_VERSION_STRING "${GAMMARAY_VERSION}")
set(GAMMARAY_SOVERSION "2.3.0")
set(GAMMARAY_PLUGIN_VERSION "2.3")
set(PROJECT_VERSION_STRING "${GAMMARAY_VERSION_STRING}")
if(ANDROID)
# non-rooted Android doesn't like .so versions...
set(GAMMARAY_DEFAULT_LIBRARY_PROPERTIES "")
else()
set(GAMMARAY_DEFAULT_LIBRARY_PROPERTIES SOVERSION ${GAMMARAY_SOVERSION} VERSION ${GAMMARAY_SOVERSION})
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
find_package(Git)
set_package_properties(Git PROPERTIES TYPE OPTIONAL PURPOSE "Determine exact build version.")
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()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-gammaray-version.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-gammaray-version.h
)
message(STATUS "Building GammaRay ${GAMMARAY_VERSION_STRING} in ${CMAKE_BUILD_TYPE} mode")
#
# Build options
#
option(
GAMMARAY_ENFORCE_QT4_BUILD
"Enable if you want to enforce a build with Qt4"
OFF
)
option(
GAMMARAY_BUILD_UI
"Build the GammaRay client and in-process UI."
ON
)
option(
GAMMARAY_PROBE_ONLY_BUILD
"Build only an additional probe configuration for an already existing launcher."
OFF
)
# 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
)
#
# Compiler & linker settings
#
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
check_cxx_compiler_flag(-Wunused-but-set-variable HAVE_GXX_UNUSED_BUT_SET)
check_cxx_compiler_flag(-Wlogical-op HAVE_GXX_LOGICAL_OP)
check_cxx_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GXX_POINTER_MEMACCESS)
check_cxx_compiler_flag(-Wreorder HAVE_GXX_REORDER)
check_cxx_compiler_flag(-Wformat-security HAVE_GXX_FORMAT_SECURITY)
check_cxx_compiler_flag(-std=c++0x HAVE_GXX_CXX11)
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 -Wmissing-noreturn -Werror=return-type")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # required in C++11 mode
endif()
if(HAVE_GXX_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
if(HAVE_GXX_UNUSED_BUT_SET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable")
endif()
if(HAVE_GXX_LOGICAL_OP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
endif()
if(HAVE_GXX_POINTER_MEMACCESS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsizeof-pointer-memaccess")
endif()
if(HAVE_GXX_REORDER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wreorder")
endif()
if(HAVE_GXX_FORMAT_SECURITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security")
endif()
if(MINGW)
# mingw will error out on the crazy casts in probe.cpp without this
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
else()
# visibility attributes not supported on mingw, don't use -fvisibility option
# see: http://stackoverflow.com/questions/7994415/mingw-fvisibility-hidden-does-not-seem-to-work
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
endif()
if(WIN32)
add_definitions(-DUNICODE -D_UNICODE)
endif()
# linker flags
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
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()
#
# Finding Qt
#
# try Qt5 first, and prefer that (if found), but only if not disabled via option
if(NOT GAMMARAY_ENFORCE_QT4_BUILD)
find_package(Qt5Core 5.1 QUIET)
else()
set(Qt5Core_FOUND FALSE)
endif()
if(Qt5Core_FOUND)
set_package_properties(Qt5Core PROPERTIES TYPE REQUIRED)
find_package(Qt5 NO_MODULE REQUIRED COMPONENTS Gui Network)
find_package(Qt5 NO_MODULE QUIET OPTIONAL_COMPONENTS
Bluetooth
Concurrent
Designer
PrintSupport
Qml
Quick
Svg
Script
ScriptTools
Test
WebKitWidgets
Widgets
)
if(GAMMARAY_BUILD_UI) # widgets are required for the UI
find_package(Qt5 NO_MODULE REQUIRED COMPONENTS Widgets)
endif()
#HACK: CMake with broken Qt5Qml_PRIVATE_INCLUDE_DIRS, Qt5Quick_PRIVATE_INCLUDE_DIRS
if(${Qt5Qml_FOUND})
if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS)
endif()
endif()
if(${Qt5Quick_FOUND})
if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme})
list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS)
endif()
endif()
include("cmake/ECMQt4To5Porting.cmake")
set(HAVE_QT_CONCURRENT ${Qt5Concurrent_FOUND})
set(HAVE_QT_WIDGETS ${Qt5Widgets_FOUND})
set(HAVE_QT_SVG ${Qt5Svg_FOUND})
set(HAVE_QT_DESIGNER ${Qt5Designer_FOUND})
set(HAVE_QT_PRINTSUPPORT ${Qt5PrintSupport_FOUND})
set(HAVE_QT_WEBKIT1 ${Qt5WebKitWidgets_FOUND})
if(Qt5_POSITION_INDEPENDENT_CODE AND NOT WIN32)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# TODO: Remove me once fixed in ECM module
# more hacks: find qpa/... includes
# also see https://codereview.qt-project.org/#change,30483
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
# TODO warnings rather than build errors for the deprecated methods would be nice...
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
find_path(QT_PRIVATE_INCLUDE_DIR private/qobject_p.h PATHS ${Qt5Core_PRIVATE_INCLUDE_DIRS})
if(QT_PRIVATE_INCLUDE_DIR)
set(HAVE_PRIVATE_QT_HEADERS true)
endif()
find_path(_Qt5Quick_PRIVATE_INCLUDE_DIR private/qquickitem_p.h PATHS ${Qt5Quick_PRIVATE_INCLUDE_DIRS})
if(_Qt5Quick_PRIVATE_INCLUDE_DIR)
set(HAVE_PRIVATE_Qt5Quick_HEADERS true)
endif()
set_package_properties(Qt5 PROPERTIES URL "http://qt-project.org/")
set_package_properties(Qt5Concurrent PROPERTIES TYPE RECOMMENDED PURPOSE "Required for the GammaRay launcher process list.")
set_package_properties(Qt5Widget PROPERTIES TYPE RECOMMENDED PURPOSE "Required for the GammaRay client UI and widget-related tools.")
set_package_properties(Qt5Svg PROPERTIES TYPE OPTIONAL PURPOSE "Required for widget SVG export.")
set_package_properties(Qt5PrintSupport PROPERTIES TYPE OPTIONAL PURPOSE "Required for widget PDF export.")
add_feature_info("QPainter analyzer" HAVE_PRIVATE_QT_HEADERS "Requires private Qt headers to be available.")
# Qt4
else()
set(QT_USE_IMPORTED_TARGETS true)
find_package(Qt4 4.8.0 REQUIRED QtCore QtGui QtNetwork)
find_package(Qt4 4.8.0 QUIET COMPONENTS QtScript QtScriptTools QtWebKit QtDesigner QtSvg QtTest)
include(${QT_USE_FILE})
set(HAVE_QT_CONCURRENT true)
set(HAVE_QT_WIDGETS true)
set(HAVE_QT_SVG true)
if(QT_QTDESIGNER_FOUND)
set(HAVE_QT_DESIGNER true)
endif()
set(HAVE_QT_PRINTSUPPORT true)
set(HAVE_QT_WEBKIT1 ${QT_QTWEBKIT_FOUND})
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()
set_package_properties(Qt4 PROPERTIES URL "http://qt-project.org/")
add_feature_info("QPainter analyzer" HAVE_PRIVATE_QT_HEADERS
"You must have a build version of Qt available. Make sure the qmake found first in your execute comes from this build version."
)
# C++11 compatibility with Qt5
add_definitions(-DQ_DECL_OVERRIDE=)
endif()
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
# disable QT_STRICT_ITERATORS on the Qt5+Windows combo
# see: https://bugreports.qt-project.org/browse/QTBUG-29608
if(NOT (Qt5Core_FOUND AND WIN32))
add_definitions(-DQT_STRICT_ITERATORS)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^[Rr]elease$")
add_definitions(-DQT_NO_DEBUG_OUTPUT)
endif()
add_feature_info("QtScript debugger" QT_QTSCRIPTTOOLS_FOUND "Requires QtScript and QtScriptTools.")
add_feature_info("Web inspector" HAVE_QT_WEBKIT1 "Requires QtWebKit.")
add_feature_info("Widget .ui file export" HAVE_QT_DESIGNER "Requires QtDesigner library.")
#
# Additional dependencies
#
if(Qt5Core_FOUND AND Qt5Core_VERSION VERSION_LESS 5.2.2)
# https://codereview.qt-project.org/75530
message(STATUS "Disabling timer profiler plug-in due to a bug in Qt5 <= 5.2.1.")
set(BUILD_TIMER_PLUGIN FALSE)
else()
if(WIN32 OR APPLE)
set(BUILD_TIMER_PLUGIN TRUE)
else()
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
gammaray_add_dummy_package(rt HAVE_CLOCK_GETTIME)
set_package_properties(rt PROPERTIES
TYPE RECOMMENDED
DESCRIPTION "High resolution clock, part of glibc"
PURPOSE "Needed for the timer profiler plugin."
)
set(BUILD_TIMER_PLUGIN ${HAVE_CLOCK_GETTIME})
endif()
endif()
check_include_files(stdint.h HAVE_STDINT_H)
set(GRAPHVIZ_MIN_VERSION "2.20")
find_package(Graphviz)
set_package_properties(Graphviz PROPERTIES
TYPE RECOMMENDED
DESCRIPTION "Graph visualization software"
URL "http://www.graphviz.org/"
PURPOSE "Needed for the state machine visualizer plugin."
)
set(HAVE_GRAPHVIZ ${GRAPHVIZ_FOUND})
if(GRAPHVIZ_FOUND)
add_definitions(-DGRAPHVIZ_MAJOR_VERSION=${GRAPHVIZ_MAJOR_VERSION} -DGRAPHVIZ_MINOR_VERSION=${GRAPHVIZ_MINOR_VERSION})
endif()
#VTK discovery works a lot better if you give CMake a hint using the VTK_DIR variable
find_path(VTK_DIR VTKConfig.cmake
/usr/lib64/vtk /usr/lib/vtk /usr/local/lib64/vtk /usr/local/lib/vtk
)
find_package(VTK)
set_package_properties(VTK PROPERTIES
TYPE OPTIONAL
DESCRIPTION "Visualization Toolkit"
PURPOSE "Needed for the object visualizer plugin."
URL "http://www.vtk.org"
)
if(VTK_FOUND)
find_path(VTK_QT_INCLUDE_DIR NAMES QVTKWidget.h HINTS ${VTK_INCLUDE_DIRS})
if(NOT VTK_QT_INCLUDE_DIR)
message(STATUS "Cannot locate QVTKWidget.h in ${VTK_INCLUDE_DIRS}")
set(VTK_FOUND FALSE)
add_feature_info("QVTKWidget header" VTK_FOUND "Object visualizer plugin requires QVTKWidget.h header.")
endif()
endif()
set(HAVE_VTK ${VTK_FOUND})
# ELF header for ABI detection
find_file(ELF_H elf.h)
if(ELF_H)
set(HAVE_ELF_H TRUE)
endif()
add_feature_info("ELF ABI detection" HAVE_ELF_H "Automatic probe ABI detection on ELF-based systems. Requires elf.h.")
#
# Determine probe ABI
# this needs to be run after we know exactly what we are building, but is needed for that installation settings
include(GammaRayProbeABI)
#
# Installation settings
#
if(APPLE)
# Make sure default prefix on mac is /Applications, dunnow why but it does not default to it
# probably because we do not enabled built in bundle support in the main project
string(COMPARE EQUAL "${CMAKE_INSTALL_PREFIX}" "/usr/local" CMP_RESULT)
if(CMP_RESULT)
set(CMAKE_INSTALL_PREFIX "/Applications")
endif()
set(BUNDLE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
set(BUNDLE_NAME "GammaRay.app")
set(BIN_INSTALL_DIR "${BUNDLE_NAME}/Contents/MacOS")
set(LIBEXEC_INSTALL_DIR "${BIN_INSTALL_DIR}")
set(LIB_INSTALL_DIR "${BUNDLE_NAME}/Contents/Frameworks")
set(PLUGIN_INSTALL_DIR "${BUNDLE_NAME}/Contents/PlugIns")
set(RESOURCES_INSTALL_DIR "${BUNDLE_NAME}/Contents/Resources")
set(DOC_INSTALL_DIR "${RESOURCES_INSTALL_DIR}/docs")
set(CMAKECONFIG_INSTALL_DIR "${RESOURCES_INSTALL_DIR}/cmake/GammaRay")
set(INCLUDE_INSTALL_DIR "${RESOURCES_INSTALL_DIR}/include/gammaray")
set(MAN_INSTALL_DIR "${RESOURCES_INSTALL_DIR}/man/man1")
else()
set(BIN_INSTALL_DIR "bin")
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
set(INCLUDE_INSTALL_DIR "include/gammaray")
set(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/GammaRay)
set(DATAROOTDIR share CACHE PATH "Define install directory for read-only architecture-independent data")
set(XDG_APPS_INSTALL_DIR "${DATAROOTDIR}/applications")
set(APPDATA_INSTALL_DIR "${DATAROOTDIR}/appdata")
set(ICON_INSTALL_DIR "${DATAROOTDIR}/icons")
set(MAN_INSTALL_DIR "${DATAROOTDIR}/man/man1")
if(WIN32)
set(PLUGIN_INSTALL_DIR "plugins")
set(LIBEXEC_INSTALL_DIR "${BIN_INSTALL_DIR}")
set(DOC_INSTALL_DIR .)
else()
set(PLUGIN_INSTALL_DIR "${LIB_INSTALL_DIR}/gammaray")
set(LIBEXEC_INSTALL_DIR "${LIB_INSTALL_DIR}/gammaray/libexec")
set(DOC_INSTALL_DIR "${DATAROOTDIR}/doc/gammaray/")
endif()
endif()
if(ANDROID)
# Android doesn't support sub-directories in lib/
set(PLUGIN_INSTALL_DIR "${LIB_INSTALL_DIR}")
set(PROBE_PLUGIN_INSTALL_DIR "${PLUGIN_INSTALL_DIR}")
else()
set(PROBE_PLUGIN_INSTALL_DIR "${PLUGIN_INSTALL_DIR}/${GAMMARAY_PLUGIN_VERSION}/${GAMMARAY_PROBE_ABI}")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${BIN_INSTALL_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIB_INSTALL_DIR})
# set RPATH only when installing to a non-default location
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" _isSystemPlatformLibDir)
list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" _isSystemCLibDir)
list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" _isSystemCxxLibDir)
if(${_isSystemPlatformLibDir} EQUAL -1 AND ${_isSystemCLibDir} EQUAL -1 AND ${_isSystemCxxLibDir} EQUAL -1)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
endif()
set(
INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Devel
BUNDLE DESTINATION ${BUNDLE_INSTALL_DIR}
)
# "inverse" install dirs, to find the base location again
gammaray_inverse_dir(GAMMARAY_INVERSE_BIN_DIR "${BIN_INSTALL_DIR}")
gammaray_inverse_dir(GAMMARAY_INVERSE_PROBE_DIR "${PROBE_PLUGIN_INSTALL_DIR}")
gammaray_inverse_dir(GAMMARAY_INVERSE_LIBEXEC_DIR "${LIBEXEC_INSTALL_DIR}")
#
# actually build the stuff
#
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-gammaray.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-gammaray.h
)
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/3rdparty
${CMAKE_BINARY_DIR}
)
add_subdirectory(cmake)
add_subdirectory(common)
add_subdirectory(core)
add_subdirectory(hooking)
if(NOT GAMMARAY_PROBE_ONLY_BUILD)
add_subdirectory(launcher)
endif()
if(GAMMARAY_BUILD_UI AND (Qt5Widgets_FOUND OR QT_QTGUI_FOUND))
add_subdirectory(ui)
add_subdirectory(inprocessui)
if(NOT GAMMARAY_PROBE_ONLY_BUILD)
add_subdirectory(client)
add_subdirectory(app)
endif()
endif()
if((Qt5Test_FOUND OR QT_QTTEST_FOUND) AND NOT CMAKE_CROSSCOMPILING)
add_subdirectory(tests)
endif()
add_subdirectory(plugins)
add_subdirectory(resources)
add_subdirectory(docs) # needs to go last, so see all installed headers for the API docs
set(LICENSE_FILE "License.txt")
set(README_FILE "ReadMe.txt")
if(NOT APPLE AND NOT GAMMARAY_PROBE_ONLY_BUILD)
if(UNIX AND GAMMARAY_BUILD_UI)
install(FILES GammaRay.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES GammaRay.appdata.xml DESTINATION ${APPDATA_INSTALL_DIR})
endif()
install(FILES "${LICENSE_FILE}" "${README_FILE}" DESTINATION ${DOC_INSTALL_DIR})
endif()
#
# cppcheck
#
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()
#
# CMake package config file generation
#
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/GammaRayConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/GammaRayConfig.cmake
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/GammaRayConfigVersion.cmake
VERSION ${GAMMARAY_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/GammaRayConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/GammaRayConfigVersion.cmake
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(
EXPORT GammaRayTargets
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
FILE GammaRayTarget.cmake
# NAMESPACE GammaRay::
)
#CPACK: General Settings
set(CPACK_GENERATOR "TBZ2")
set(CPACK_PACKAGE_NAME "gammaray")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An introspection tool for Qt applications")
#TODO: shorten lines in the Readme.txt to make rpmlint happy
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/${README_FILE}")
set(CPACK_PACKAGE_VENDOR "Klaralvdalens Datakonsult AB (KDAB)")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_VERSION_MAJOR "${GAMMARAY_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${GAMMARAY_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${GAMMARAY_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${GAMMARAY_VERSION}")
#CPACK: RPM Specific Settings
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2+")
set(CPACK_RPM_PACKAGE_GROUP "Development/Tools")
#CPACK: DEB Specific Settings
set(CPACK_DEBIAN_PACKAGE_SECTION "Development")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/${README_FILE}")
if(WIN32)
set(CPACK_GENERATOR "NSIS" "ZIP")
set(CPACK_PACKAGE_EXECUTABLES "GammaRay" "GammaRay")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "GammaRay")
set(CPACK_PACKAGE_FILE_NAME "GammaRay ${GAMMARAY_VERSION}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/${LICENSE_FILE}")
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${BIN_INSTALL_DIR}")
set(CPACK_NSIS_MUI_ICON "${ICONS_DIR}/Charm.ico")
set(CPACK_PACKAGE_ICON "${ICONS_DIR}\\\\CharmNSISHeader.bmp")
set(CPACK_NSIS_URL_INFO_ABOUT "http://www.kdab.com/")
set(CPACK_NSIS_INSTALLED_ICON_NAME "GammaRay${CMAKE_EXECUTABLE_SUFFIX}")
set(CPACK_NSIS_MENU_LINKS
"${LICENSE_FILE}" "License"
"${README_FILE}" "Readme"
)
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CPACK_NSIS_INSTALLED_ICON_NAME}")
elseif(APPLE)
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "GammaRay")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_FILE_NAME "GammaRay-${GAMMARAY_VERSION}")
set(CPACK_PACKAGE_ICON "${ICONS_DIR}/CharmDMG.icns")
set(CPACK_DMG_DS_STORE "${ICONS_DIR}/CharmDSStore")
set(CPACK_DMG_BACKGROUND_IMAGE "${ICONS_DIR}/CharmDMGBackground.png")
elseif(UNIX)
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
endif()
include(CPack)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)