forked from NatronGitHub/stackwalker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
212 lines (194 loc) · 6.41 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
#
# Copyright (C) 2019 Ole-André Rodlie
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
cmake_minimum_required(VERSION 3.0)
project(stackwalker VERSION 20190823)
if(NOT PROJECT_VERSION_TWEAK)
set(PROJECT_VERSION_TWEAK 0)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(BREAKPAD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/breakpad)
set(BREAKPAD_BIN ${CMAKE_BINARY_DIR}/breakpad)
set(STACKWALKER ${CMAKE_CURRENT_SOURCE_DIR}/minidump-stackwalk)
set(BREAKDOWN ${CMAKE_CURRENT_SOURCE_DIR}/breakdown)
set(BREAKDOWN_URL "https://stackwalker.000webhostapp.com")
set(COMPANY "FxArena")
set(COPYRIGHT "Copyright Ole-Andre Rodlie, FxArena. All rights reserved.")
set(IDENTIFIER "net.fxarena.breakdown")
file(MAKE_DIRECTORY ${BREAKPAD_BIN})
option(MXE32_STATIC "Build using MXE i686 static" OFF)
option(MXE64_STATIC "Build using MXE x86_64 static" OFF)
option(MXE32_SHARED "Build using MXE i686 shared" OFF)
option(MXE64_SHARED "Build using MXE x86_64 shared" OFF)
option(USE_QT4 "Build using Qt4" OFF)
if(USE_QT4)
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork)
else()
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Concurrent REQUIRED)
#find_package(Qt5Test REQUIRED)
endif()
find_package(PkgConfig REQUIRED)
find_package(Git QUIET)
pkg_search_module(CURL REQUIRED libcurl)
pkg_search_module(ZIP REQUIRED libzip)
pkg_search_module(JSON REQUIRED jsoncpp)
if(WIN32)
set(ICON_FILE ${BREAKDOWN}/breakdown.ico)
endif()
if(NOT EXISTS ${BREAKPAD_SRC}/configure)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
if(NOT EXISTS ${BREAKPAD_BIN}/src/libbreakpad.a)
message("-- MISSING BREAKPAD (will try to build)")
if(MXE32_STATIC)
set(BREAKPAD_OPTIONS "--host=i686-w64-mingw32.static")
elseif(MXE64_STATIC)
set(BREAKPAD_OPTIONS "--host=x86_64-w64-mingw32.static")
elseif(MXE32_SHARED)
set(BREAKPAD_OPTIONS "--host=i686-w64-mingw32.shared")
elseif(MXE64_SHARED)
set(BREAKPAD_OPTIONS "--host=x86_64-w64-mingw32.shared")
endif()
execute_process(
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_breakpad.sh ${BREAKPAD_SRC} ${BREAKPAD_OPTIONS}
WORKING_DIRECTORY ${BREAKPAD_BIN}
)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(release|Release|RELEASE)$")
add_definitions(-DQT_NO_DEBUG_OUTPUT)
else()
message("-- DEBUG BUILD")
endif()
add_compile_options(-Wall -Wextra ${CURL_CFLAGS})
add_definitions(-D__STDC_FORMAT_MACROS=1 -Wno-format)
add_definitions(-DBREAKDOWN_URL="${BREAKDOWN_URL}")
add_definitions(-DBREAKDOWN_VERSION="${PROJECT_VERSION}")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${BREAKDOWN}
${BREAKPAD_SRC}/src
${STACKWALKER}
${CURL_INCLUDE_DIRS}
${ZIP_INCLUDE_DIRS}
${JSON_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/qjson4
)
if(USE_QT4)
add_executable(
breakdown
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonArray.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonDocument.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonObject.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonParseError.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonValue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonValueRef.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qjson4/QJsonParser.cpp
${STACKWALKER}/http_symbol_supplier.cc
${BREAKDOWN}/main.cpp
${BREAKDOWN}/breakdown.cpp
${BREAKDOWN}/authdialog.cpp
${BREAKDOWN}/breakdown.ui
${BREAKDOWN}/breakdown.qrc
)
else()
add_executable(
breakdown
${STACKWALKER}/http_symbol_supplier.cc
${BREAKDOWN}/main.cpp
${BREAKDOWN}/breakdown.cpp
${BREAKDOWN}/authdialog.cpp
${BREAKDOWN}/breakdown.ui
${BREAKDOWN}/breakdown.qrc
)
endif()
add_executable(
stackwalker
${STACKWALKER}/http_symbol_supplier.cc
${STACKWALKER}/stackwalker.cc
)
if(USE_QT4)
target_link_libraries(
breakdown
Qt4::QtCore
Qt4::QtGui
Qt4::QtNetwork
${BREAKPAD_BIN}/src/libbreakpad.a
${BREAKPAD_BIN}/src/third_party/libdisasm/libdisasm.a
${CURL_STATIC_LIBRARIES}
${ZIP_STATIC_LIBRARIES}
${JSON_STATIC_LIBRARIES}
)
else()
target_link_libraries(
breakdown
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
Qt5::Concurrent
${BREAKPAD_BIN}/src/libbreakpad.a
${BREAKPAD_BIN}/src/third_party/libdisasm/libdisasm.a
${CURL_STATIC_LIBRARIES}
${ZIP_STATIC_LIBRARIES}
${JSON_STATIC_LIBRARIES}
)
endif()
target_link_libraries(
stackwalker
${BREAKPAD_BIN}/src/libbreakpad.a
${BREAKPAD_BIN}/src/third_party/libdisasm/libdisasm.a
${CURL_STATIC_LIBRARIES}
${ZIP_STATIC_LIBRARIES}
${JSON_STATIC_LIBRARIES}
)
if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
install(
TARGETS
breakdown
stackwalker
DESTINATION
${CMAKE_INSTALL_BINDIR}
)
install(
FILES
${BREAKPAD_BIN}/src/tools/linux/dump_syms/dump_syms
DESTINATION
${CMAKE_INSTALL_BINDIR}
)
#install(DIRECTORY ${RESOURCE_FOLDER}/hicolor DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons)
#install(FILES ${RESOURCE_FOLDER}/breakdown.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
install(
FILES
COPYING
README.md
DESTINATION
${CMAKE_INSTALL_DOCDIR}-${PROJECT_VERSION}
)
endif()