2018-02-20 00:12:04 +08:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
|
|
|
project(breakpad CXX)
|
|
|
|
|
2018-08-08 21:02:30 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2018-02-20 00:12:04 +08:00
|
|
|
add_definitions(
|
|
|
|
-DNOMINMAX
|
|
|
|
-DUNICODE
|
|
|
|
-DWIN32_LEAN_AND_MEAN
|
|
|
|
-D_CRT_SECURE_NO_WARNINGS
|
|
|
|
-D_CRT_SECURE_NO_DEPRECATE
|
|
|
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
2018-08-08 21:02:30 +08:00
|
|
|
-D_LIBCPP_VERSION
|
2018-02-20 00:12:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_DEBUG_POSTFIX d)
|
|
|
|
|
|
|
|
string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "Release" DEFAULT_INSTALL_HEADERS)
|
|
|
|
option(INSTALL_HEADERS "Install header files" ${DEFAULT_INSTALL_HEADERS})
|
|
|
|
|
2018-08-08 21:02:30 +08:00
|
|
|
# libbreakpad target
|
|
|
|
file(GLOB_RECURSE LIBBREAKPAD_SOURCES src/processor/*.cc)
|
2020-12-17 16:16:41 +08:00
|
|
|
if(WIN32)
|
|
|
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX
|
|
|
|
"_unittest|synth_minidump|/tests|/testdata|/linux|/mac|/android|/solaris|microdump_stackwalk|minidump_dump|minidump_stackwalk")
|
|
|
|
elseif(APPLE)
|
|
|
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX
|
|
|
|
"_unittest|synth_minidump|/tests|/testdata|/linux|/windows|/android|/solaris|microdump_stackwalk|minidump_dump|minidump_stackwalk")
|
|
|
|
else()
|
|
|
|
list(FILTER LIBBREAKPAD_SOURCES EXCLUDE REGEX
|
|
|
|
"_unittest|synth_minidump|/tests|/testdata|/mac|/windows|/android|/solaris|microdump_stackwalk|minidump_dump|minidump_stackwalk")
|
|
|
|
endif()
|
2018-02-20 00:12:04 +08:00
|
|
|
|
|
|
|
find_library(LIBDISASM_LIB NAMES libdisasmd libdisasm)
|
|
|
|
|
2018-08-08 21:02:30 +08:00
|
|
|
add_library(libbreakpad ${LIBBREAKPAD_SOURCES})
|
2018-02-20 00:12:04 +08:00
|
|
|
target_link_libraries(libbreakpad PRIVATE ${LIBDISASM_LIB})
|
|
|
|
|
|
|
|
target_include_directories(libbreakpad
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
)
|
|
|
|
|
2018-08-08 21:02:30 +08:00
|
|
|
set(TARGETS libbreakpad)
|
|
|
|
if(WIN32)
|
2020-12-17 16:16:41 +08:00
|
|
|
file(GLOB_RECURSE LIBBREAKPAD_CLIENT_SOURCES src/client/windows/*.cc src/common/windows/*.cc)
|
|
|
|
include_directories("$ENV{VSINSTALLDIR}/DIA SDK/include")
|
|
|
|
elseif(APPLE)
|
|
|
|
add_definitions(-DHAVE_MACH_O_NLIST_H)
|
|
|
|
file(GLOB_RECURSE LIBBREAKPAD_CLIENT_SOURCES src/client/mac/*.cc src/common/mac/*.cc)
|
|
|
|
list(APPEND LIBBREAKPAD_CLIENT_SOURCES src/common/mac/MachIPC.mm)
|
|
|
|
else()
|
|
|
|
add_definitions(-DHAVE_A_OUT_H)
|
|
|
|
file(GLOB_RECURSE LIBBREAKPAD_CLIENT_SOURCES src/client/linux/*.cc src/common/linux/*.cc)
|
|
|
|
endif()
|
|
|
|
file(GLOB LIBBREAKPAD_COMMON_SOURCES src/common/*.cc src/common/*.c src/client/*.cc)
|
|
|
|
list(APPEND LIBBREAKPAD_CLIENT_SOURCES ${LIBBREAKPAD_COMMON_SOURCES})
|
|
|
|
list(FILTER LIBBREAKPAD_CLIENT_SOURCES EXCLUDE REGEX "/sender|/tests|/unittests|/testcases|_unittest|_test")
|
|
|
|
if(WIN32)
|
|
|
|
list(FILTER LIBBREAKPAD_CLIENT_SOURCES EXCLUDE REGEX "language.cc|path_helper.cc|stabs_to_module.cc|stabs_reader.cc|minidump_file_writer.cc")
|
|
|
|
elseif(NOT APPLE)
|
|
|
|
try_compile(HAVE_GETCONTEXT ${CMAKE_BINARY_DIR}/check_getcontext ${CMAKE_CURRENT_LIST_DIR}/check_getcontext.cc OUTPUT_VARIABLE BUILD_OUT)
|
|
|
|
if (NOT HAVE_GETCONTEXT)
|
|
|
|
enable_language(ASM)
|
|
|
|
list(APPEND LIBBREAKPAD_CLIENT_SOURCES src/common/linux/breakpad_getcontext.S)
|
2018-08-08 21:02:30 +08:00
|
|
|
endif()
|
2020-12-17 16:16:41 +08:00
|
|
|
endif()
|
2018-08-08 21:02:30 +08:00
|
|
|
|
2020-12-17 16:16:41 +08:00
|
|
|
add_library(libbreakpad_client ${LIBBREAKPAD_CLIENT_SOURCES})
|
|
|
|
if(WIN32)
|
2018-08-08 21:02:30 +08:00
|
|
|
target_link_libraries(libbreakpad_client PRIVATE wininet.lib)
|
2020-12-17 16:16:41 +08:00
|
|
|
elseif(APPLE)
|
|
|
|
find_library(CoreFoundation_FRAMEWORK CoreFoundation)
|
|
|
|
target_link_libraries(libbreakpad_client PRIVATE ${CoreFoundation_FRAMEWORK})
|
|
|
|
else()
|
|
|
|
find_library(PTHREAD_LIBRARIES pthread)
|
|
|
|
target_link_libraries(libbreakpad_client PRIVATE ${PTHREAD_LIBRARIES})
|
|
|
|
if (HAVE_GETCONTEXT)
|
|
|
|
target_compile_definitions(libbreakpad_client PRIVATE HAVE_GETCONTEXT=1)
|
|
|
|
endif()
|
2018-08-08 21:02:30 +08:00
|
|
|
endif()
|
|
|
|
|
2020-12-17 16:16:41 +08:00
|
|
|
target_include_directories(libbreakpad_client
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
)
|
|
|
|
list(APPEND TARGETS libbreakpad_client)
|
|
|
|
|
2018-08-08 21:02:30 +08:00
|
|
|
# installation
|
|
|
|
install(TARGETS ${TARGETS} EXPORT unofficial-breakpad-targets
|
2018-02-20 00:12:04 +08:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
|
|
|
|
if(INSTALL_HEADERS)
|
2018-08-08 21:02:30 +08:00
|
|
|
if(WIN32)
|
|
|
|
set(HEADER_EXCLUDE_REGEX "/apple|/ios|/linux|/mac|/solaris|/android|/dwarf|/tests|/testdata|/unittests")
|
|
|
|
elseif(APPLE)
|
2020-12-17 16:16:41 +08:00
|
|
|
set(HEADER_EXCLUDE_REGEX "/apple|/ios|/linux|/windows|/solaris|/android|/dwarf|/tests|/testdata|/unittests|/sender|/testapp|/*proj|/gcov")
|
2018-08-08 21:02:30 +08:00
|
|
|
else()
|
|
|
|
set(HEADER_EXCLUDE_REGEX "/apple|/ios|/client/linux/data|/client/linux/sender|/windows|/mac|/solaris|/android|/dwarf|/tests|/testdata|/unittests")
|
2020-12-17 16:16:41 +08:00
|
|
|
install(
|
|
|
|
DIRECTORY src/third_party/lss
|
|
|
|
DESTINATION include/third_party
|
|
|
|
FILES_MATCHING PATTERN "*.h"
|
|
|
|
REGEX "${HEADER_EXCLUDE_REGEX}" EXCLUDE
|
|
|
|
)
|
2018-08-08 21:02:30 +08:00
|
|
|
endif()
|
|
|
|
install(
|
|
|
|
DIRECTORY src/client src/common src/google_breakpad
|
|
|
|
DESTINATION include/
|
2020-06-18 02:19:55 +08:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.h"
|
|
|
|
REGEX ${HEADER_EXCLUDE_REGEX} EXCLUDE
|
2018-08-08 21:02:30 +08:00
|
|
|
)
|
2018-02-20 00:12:04 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install(
|
|
|
|
EXPORT unofficial-breakpad-targets
|
|
|
|
FILE unofficial-breakpad-config.cmake
|
|
|
|
NAMESPACE unofficial::breakpad::
|
|
|
|
DESTINATION share/unofficial-breakpad
|
|
|
|
)
|