-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
128 lines (105 loc) · 3.73 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
cmake_minimum_required(VERSION 3.11)
project(crashpad LANGUAGES C CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
if(MSVC)
enable_language(ASM_MASM)
else()
enable_language(ASM)
endif()
# Option to build unit tests.
option(CRASHPAD_BUILD_TESTS "Build unit tests." OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# We are going to use the FetchContent module to grab crashpad and its dependencies.
include(FetchContent)
# Try to find prebuilt zlib on the system to link against first before building it ourselves.
find_package(ZLIB 1.2.8)
# If not found, we fetch it and build it ourselves.
if(NOT ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)
FetchContent_Declare(
zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.11
)
# We don't use FetchContent_MakeAvailable here because we don't want all zlib targets including, just our dependency.
FetchContent_GetProperties(zlib)
if(NOT zlib_POPULATED)
FetchContent_Populate(zlib)
add_subdirectory(${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
# Make sure headers are available for the static target and make an alias to match the Find module output.
target_include_directories(zlibstatic INTERFACE ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR})
add_library(ZLIB::ZLIB ALIAS zlibstatic)
endif()
find_package(Threads)
add_library(AppleFrameworks INTERFACE)
if(APPLE)
set(FRAMEWORKS CoreFoundation;ApplicationServices;Foundation;IOKit;Security;bsm;OpenCL)
foreach(FW ${FRAMEWORKS})
find_library(FW_PATH_${FW} ${FW})
target_link_libraries(AppleFrameworks INTERFACE ${FW_PATH_${FW}})
endforeach()
endif()
# Mini-Chromium
FetchContent_Declare(
mini_chromium_git
GIT_REPOSITORY https://github.com/chromium/mini_chromium.git
GIT_TAG 9cdc2a7
)
if(NOT mini_chromium_git_POPULATED)
FetchContent_Populate(mini_chromium_git)
endif()
# Crashpad
FetchContent_Declare(
crashpad_git
GIT_REPOSITORY https://github.com/backtrace-labs/crashpad.git
GIT_TAG 7b9686b
)
if(NOT crashpad_git_POPULATED)
FetchContent_Populate(crashpad_git)
endif()
# LSS dependency for linux syscalls.
FetchContent_Declare(
lss_git
GIT_REPOSITORY https://chromium.googlesource.com/linux-syscall-support
GIT_TAG e1e7b0a
)
if(NOT lss_git_POPULATED)
FetchContent_Populate(lss_git)
endif()
file(COPY ${lss_git_SOURCE_DIR}/linux_syscall_support.h DESTINATION ${crashpad_git_SOURCE_DIR}/third_party/lss)
include(crashpad-common)
include(minichromium)
include(crashpad-compat)
include(crashpad-tools)
include(crashpad-util)
include(crashpad-client)
include(crashpad-minidump)
include(crashpad-snapshot)
include(crashpad-handler)
# If we want unit tests, build them.
if(CRASHPAD_BUILD_TESTS)
# Disable tests supplied by zlib source incase we have to build it.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CTestCustom.cmake ${CMAKE_BINARY_DIR})
enable_testing()
# Fetch googletest code.
include(GoogleTest)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
)
# We don't use FetchContent_MakeAvailable here because we don't want all googletest targets including, just our dependencies.
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
endif()
include(gtest)
include(crashpad-test)
include(crashpad-test-test)
include(crashpad-util-test)
include(crashpad-snapshot-test)
include(crashpad-minidump-test)
include(crashpad-client-test)
include(crashpad-handler-test)
endif()