forked from facebook/redex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
170 lines (139 loc) · 4.33 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
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.0.2)
project("Redex")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
include(Commons)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if(NOT BUILD_TYPE)
set(BUILD_TYPE Shared)
endif ()
if (MINGW)
set(BUILD_TYPE Static)
endif ()
if(BUILD_TYPE STREQUAL Static)
set(ENABLE_STATIC ON CACHE BOOL "" FORCE)
if (MINGW)
set(STATIC_LINK_FLAG "-static")
else (MINGW)
set(STATIC_LINK_FLAG "")
endif (MINGW)
elseif (BUILD_TYPE STREQUAL Shared)
set(ENABLE_STATIC OFF CACHE BOOL "" FORCE)
set(STATIC_LINK_FLAG "")
endif ()
set_common_cxx_flags_for_redex()
add_dependent_packages_for_redex()
file(GLOB includes
"analysis"
"libredex"
"service/*"
"opt/*"
"util"
"liblocator"
"libresource"
"shared"
"sparta/include"
"tools/common"
)
include_directories(
${Boost_INCLUDE_DIRS}
${JSONCPP_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${includes})
install(DIRECTORY libredex util libresource shared service
DESTINATION include/redex
FILES_MATCHING PATTERN "*.h" PATTERN "*.def")
install(DIRECTORY sparta/include/
DESTINATION include/redex/sparta
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY tools/common tools/tool
DESTINATION include/redex/tools
FILES_MATCHING PATTERN "*.h")
file(GLOB_RECURSE redex_srcs
"analysis/max-depth/*.cpp"
"analysis/max-depth/*.h"
"analysis/ip-reflection-analysis/*.cpp"
"analysis/ip-reflection-analysis/*.h"
"libredex/*.cpp"
"libredex/*.h"
"service/*.cpp"
"service/*.h"
"opt/*.cpp"
"opt/*.h"
"util/CommandProfiling.cpp"
"util/CommandProfiling.h"
"util/JemallocUtil.cpp"
"util/JemallocUtil.h"
"util/Sha1.cpp"
"util/Sha1.h"
"shared/DexDefs.cpp"
"shared/DexDefs.h"
"shared/DexEncoding.cpp"
"shared/DexEncoding.h"
"shared/file-utils.cpp"
"shared/file-utils.h"
"liblocator/locator.cpp"
"liblocator/locator.h"
)
add_library(redex STATIC ${redex_srcs})
install(TARGETS redex ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
file(GLOB_RECURSE tool_srcs
"tools/tool/*.cpp"
"tools/tool/*.h"
)
add_library(tool STATIC ${tool_srcs})
install(TARGETS tool ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
file(GLOB_RECURSE resource_srcs
"libresource/*.cpp"
"libresource/*.h"
)
add_library(resource STATIC ${resource_srcs})
install(TARGETS resource ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
file(GLOB redex_all_srcs
"tools/redex-all/*.cpp"
"tools/redex-all/*.h"
"tools/common/ToolsCommon.cpp"
"tools/common/ToolsCommon.h"
)
add_executable(redex-all ${redex_all_srcs})
if (MINGW)
set(MINGW_EXTRA_LIBS -Wl,-Bstatic ws2_32)
else (MINGW)
set(MINGW_EXTRA_LIBS "")
endif (MINGW)
target_link_libraries(redex-all
${STATIC_LINK_FLAG}
${Boost_LIBRARIES}
${REDEX_JSONCPP_LIBRARY}
${REDEX_ZLIB_LIBRARY}
${CMAKE_DL_LIBS}
redex
resource
${MINGW_EXTRA_LIBS}
m
)
target_compile_definitions(redex-all PRIVATE)
set_link_whole(redex-all redex)
install(TARGETS redex-all DESTINATION bin)
# redex.py things...
install(FILES redex.py DESTINATION bin)
install(DIRECTORY pyredex DESTINATION bin)
file(GLOB gen_packed_apilevels "gen_packed_apilevels.py")
file(GLOB api_level_srcs "service/api-levels/framework_classes_api_*.txt")
add_custom_command(
OUTPUT generated_apilevels.py
COMMAND python3 ${gen_packed_apilevels} -o generated_apilevels.py ${api_level_srcs}
DEPENDS ${api_level_srcs} ${gen_packed_apilevels}
)
add_custom_target(generated_apilevels ALL DEPENDS generated_apilevels.py)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/generated_apilevels.py DESTINATION bin)
# Misc stuff, for good measure.
install(FILES LICENSE README.md config/default.config DESTINATION share/doc/redex)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_GENERATOR "ZIP")
include(CPack)