1
- cmake_minimum_required (VERSION 3.0 )
1
+ cmake_minimum_required (VERSION 3.10 )
2
2
project (crashpad LANGUAGES C CXX)
3
3
4
+ set (CRASHPAD_MAIN_PROJECT OFF )
5
+ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR )
6
+ set (CRASHPAD_MAIN_PROJECT ON )
7
+ endif ()
8
+
9
+ option (CRASHPAD_ENABLE_INSTALL "Enable crashpad installation" "${CRASHPAD_MAIN_PROJECT} " )
10
+ option (CRASHPAD_ENABLE_INSTALL_DEV "Enable crashpad development installation" "${CRASHPAD_MAIN_PROJECT} " )
11
+
12
+ if (MSVC )
13
+ set (CRASHPAD_ZLIB_SYSTEM_DEFAULT OFF )
14
+ else ()
15
+ set (CRASHPAD_ZLIB_SYSTEM_DEFAULT ON )
16
+ endif ()
17
+ option (CRASHPAD_ZLIB_SYSTEM "Use system zlib library" "${CRASHPAD_ZLIB_SYSTEM_DEFAULT} " )
18
+
19
+ if (CRASHPAD_ZLIB_SYSTEM)
20
+ find_package (ZLIB REQUIRED)
21
+ endif ()
22
+
23
+ include (GNUInstallDirs)
24
+ set (CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR} /cmake/crashpad" )
25
+
26
+ function (crashpad_install_target)
27
+ if (CRASHPAD_ENABLE_INSTALL)
28
+ install (TARGETS ${ARGN} EXPORT crashpad_export
29
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR} "
30
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR} "
31
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR} "
32
+ )
33
+ endif ()
34
+ endfunction ()
35
+ function (crashpad_install_dev)
36
+ if (CRASHPAD_ENABLE_INSTALL_DEV)
37
+ install (${ARGN} )
38
+ endif ()
39
+ endfunction ()
40
+
41
+ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" )
42
+ set (LINUX TRUE )
43
+ endif ()
44
+
4
45
if (WIN32 )
5
46
enable_language (ASM_MASM)
6
47
IF (MINGW)
@@ -9,86 +50,73 @@ if(WIN32)
9
50
SET (CMAKE_ASM_MASM_COMPILER "uasm" )
10
51
SET (CMAKE_ASM_MASM_FLAGS "-win64 -10" )
11
52
else ()
12
- message (FATAL_ERROR "UASM is required for MinGW builds ! Make sure you have it installed" )
53
+ message (FATAL_ERROR "UASM is required for MinGW builds! Make sure you have it installed" )
13
54
endif ()
14
55
endif ()
15
56
else ()
16
57
enable_language (ASM)
17
58
endif ()
18
59
19
60
set (CMAKE_CXX_STANDARD 14)
20
- set (CMAKE_CXX_STANDARD_REQUIRED True )
21
-
22
- if (CMAKE_SYSTEM_NAME STREQUAL "Linux" )
23
- set (LINUX TRUE )
24
- endif ()
61
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
25
62
26
- include_directories ("${CMAKE_CURRENT_SOURCE_DIR} " )
27
- include_directories ("${CMAKE_CURRENT_SOURCE_DIR} /third_party/mini_chromium/mini_chromium" )
28
-
29
- # These should really be in `compat`, but we want them for the whole project
30
- if (APPLE )
31
- include_directories (SYSTEM "compat/mac" )
32
- else ()
33
- include_directories (PUBLIC "compat/non_mac" )
34
- endif ()
35
-
36
- if (LINUX OR ANDROID)
37
- include_directories (SYSTEM "compat/linux" )
38
- endif ()
39
- if (ANDROID)
40
- include_directories (SYSTEM "compat/android" )
41
- endif ()
42
-
43
- if (MSVC )
44
- include_directories (SYSTEM "compat/win" )
45
- elseif (MINGW)
46
- include_directories (PUBLIC "compat/mingw" )
47
- else ()
48
- include_directories (PUBLIC "compat/non_win" )
49
- endif ()
50
-
51
- if (NOT LINUX AND NOT ANDROID)
52
- include_directories (SYSTEM "compat/non_elf" )
53
- endif ()
63
+ add_library (crashpad_interface INTERFACE )
64
+ target_include_directories (crashpad_interface INTERFACE
65
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} >
66
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third_party/mini_chromium/mini_chromium>
67
+ )
68
+ target_compile_definitions (crashpad_interface INTERFACE
69
+ CRASHPAD_LSS_SOURCE_EMBEDDED
70
+ )
54
71
55
72
if (MSVC )
56
- add_definitions (
57
- /DNOMINMAX
58
- /DUNICODE
59
- /DWIN32_LEAN_AND_MEAN
60
- /D_CRT_SECURE_NO_WARNINGS
61
- /D_HAS_EXCEPTIONS=0
62
- /D_UNICODE
63
- /FS
64
- /W4
65
- /WX
66
- /Zi
67
- /bigobj # Support larger number of sections in obj file.
68
- /wd4100 # Unreferenced formal parameter.
69
- /wd4127 # Conditional expression is constant.
70
- /wd4324 # Structure was padded due to alignment specifier.
71
- /wd4351 # New behavior: elements of array will be default initialized.
72
- /wd4577 # 'noexcept' used with no exception handling mode specified.
73
- /wd4996 # 'X' was declared deprecated.
73
+ target_compile_definitions (crashpad_interface INTERFACE
74
+ NOMINMAX
75
+ UNICODE
76
+ WIN32_LEAN_AND_MEAN
77
+ _CRT_SECURE_NO_WARNINGS
78
+ _HAS_EXCEPTIONS=0
79
+ _UNICODE
74
80
)
75
- elseif (MINGW)
76
- #redirect to wmain
77
- add_link_options (
78
- -municode
81
+ target_compile_options (crashpad_interface INTERFACE
82
+ $<$<COMPILE_LANGUAGE:C,CXX>:/FS>
83
+ $<$<COMPILE_LANGUAGE:C,CXX>:/W4>
84
+ $<$<COMPILE_LANGUAGE:C,CXX>:/WX>
85
+ $<$<COMPILE_LANGUAGE:C,CXX>:/Zi>
86
+ $<$<COMPILE_LANGUAGE:C,CXX>:/bigobj> # Support larger number of sections in obj file.
87
+ $<$<COMPILE_LANGUAGE:C,CXX>:/wd4100> # Unreferenced formal parameter.
88
+ $<$<COMPILE_LANGUAGE:C,CXX>:/wd4127> # Conditional expression is constant.
89
+ $<$<COMPILE_LANGUAGE:C,CXX>:/wd4324> # Structure was padded due to alignment specifier.
90
+ $<$<COMPILE_LANGUAGE:C,CXX>:/wd4351> # New behavior: elements of array will be default initialized.
91
+ $<$<COMPILE_LANGUAGE:C,CXX>:/wd4577> # 'noexcept' used with no exception handling mode specified.
92
+ $<$<COMPILE_LANGUAGE:C,CXX>:/wd4996> # 'X' was declared deprecated.
79
93
)
94
+ elseif (MINGW)
95
+ # redirect to wmain
96
+ # FIXME: cmake 3.13 added target_link_options
97
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode" )
80
98
endif ()
99
+ add_library (crashpad::interface ALIAS crashpad_interface)
81
100
82
- add_subdirectory (client)
83
101
add_subdirectory (compat)
84
- add_subdirectory (handler)
85
102
add_subdirectory (minidump)
86
103
add_subdirectory (snapshot)
87
- add_subdirectory (tools)
88
104
add_subdirectory (util)
89
105
add_subdirectory (third_party/mini_chromium)
106
+ add_subdirectory (client)
90
107
91
- if (MSVC )
92
- add_subdirectory (third_party/getopt)
93
- add_subdirectory (third_party/zlib)
94
- endif ()
108
+ add_subdirectory (third_party/zlib)
109
+ add_subdirectory (third_party/getopt)
110
+
111
+ add_subdirectory (tools)
112
+ add_subdirectory (handler)
113
+
114
+ if (CRASHPAD_ENABLE_INSTALL_DEV)
115
+ install (EXPORT crashpad_export NAMESPACE crashpad:: FILE crashpad-targets.cmake
116
+ DESTINATION "${CMAKE_INSTALL_CMAKEDIR} " )
117
+ include (CMakePackageConfigHelpers)
118
+ configure_package_config_file(crashpad-config.cmake.in crashpad-config.cmake
119
+ INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR} "
120
+ )
121
+ install (FILES "${CMAKE_CURRENT_BINARY_DIR} /crashpad-config.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR} " )
122
+ endif ()
0 commit comments