forked from googleprojectzero/TinyInst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·142 lines (126 loc) · 3.83 KB
/
CMakeLists.txt
File metadata and controls
executable file
·142 lines (126 loc) · 3.83 KB
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
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION "3.1")
set (CMAKE_CXX_STANDARD 17)
# Determine whether TinyInst should be build for arm64 or x86
if(APPLE AND NOT DEFINED ${ARCHITECTURE})
EXECUTE_PROCESS(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE)
if(${ARCHITECTURE} MATCHES arm64)
add_definitions(-DARM64)
endif()
endif()
add_subdirectory(third_party)
project("tinyinst")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/obj/wkit/include)
if(${ARCHITECTURE} MATCHES arm64)
set (arch_specific_files
arch/arm64/reg.h
arch/arm64/arm64_helpers.h
arch/arm64/arm64_helpers.cpp
arch/arm64/arm64_assembler.h
arch/arm64/arm64_assembler.cpp
arch/arm64/arm64_litecov.cpp
)
else()
set (arch_specific_files
arch/x86/reg.h
arch/x86/x86_helpers.h
arch/x86/x86_helpers.cpp
arch/x86/x86_assembler.h
arch/x86/x86_assembler.cpp
arch/x86/x86_litecov.cpp
)
endif()
set (cross_platform_files
common.h
common.cpp
assembler.h
instruction.h
tinyinst.h
tinyinst.cpp
coverage.h
coverage.cpp
litecov.h
litecov.cpp
unwind.h
)
if (WIN32)
set (platform_specific_files
Windows/debugger.h
Windows/debugger.cpp
Windows/winunwind.cpp
Windows/winunwind.h
)
elseif (APPLE)
if (${ARCHITECTURE} MATCHES arm64)
set(CMAKE_REQUIRED_LINK_OPTIONS "-arch;arm64")
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_client.c
${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_server.c
${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_client.h
${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_server.h
COMMAND mig -user ${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_client.c
-server ${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_server.c
-header ${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_client.h
-sheader ${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig_server.h
${CMAKE_CURRENT_SOURCE_DIR}/macOS/mig.defs
COMMENT "Generating Mig files"
)
set (platform_specific_files
macOS/debugger.h
macOS/debugger.cpp
macOS/machtarget.h
macOS/machtarget.cpp
macOS/mig_client.h
macOS/mig_client.c
macOS/mig_server.h
macOS/mig_server.c
macOS/unwindmacos.cpp
macOS/unwindmacos.h
macOS/dyld_cache_map_parser.cpp
macOS/dyld_cache_map_parser.h
)
endif()
add_library(tinyinst STATIC
${arch_specific_files}
${arch_specific_files}
${platform_specific_files}
${cross_platform_files}
)
target_include_directories(tinyinst PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/third_party/obj/wkit/include
)
if((${ARCHITECTURE} MATCHES arm64) AND APPLE)
add_dependencies(tinyinst reil)
target_link_libraries(tinyinst reil)
else()
add_dependencies(tinyinst xed)
if (WIN32)
target_link_libraries(tinyinst
${CMAKE_CURRENT_BINARY_DIR}/third_party/obj/wkit/lib/xed.lib
Dbghelp.lib
)
elseif (APPLE)
target_link_libraries(tinyinst
${CMAKE_CURRENT_BINARY_DIR}/third_party/obj/wkit/lib/libxed.a
)
endif()
endif()
project("litecov")
add_executable(litecov
tinyinst-coverage.cpp
)
target_link_libraries(litecov tinyinst)