-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
CMakeLists.txt
143 lines (121 loc) · 4.25 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
cmake_minimum_required(VERSION 3.0)
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
project(rz-ghidra)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Rizin REQUIRED Core)
set(RIZIN_INSTALL_PLUGDIR "${Rizin_PLUGINDIR}" CACHE STRING "Directory to install rizin plugins into")
option(BUILD_CUTTER_PLUGIN "Build rz-ghidra plugin for Cutter" OFF)
option(BUILD_DECOMPILE_EXECUTABLE "Build \"decompile\" executable as used by Ghidra (not needed for rizin)" OFF)
option(BUILD_DECOMPILE_CLI_EXECUTABLE "Build REPL decompiler (not needed for rizin)" OFF)
option(BUILD_SLASPECS "Build Sleigh specs for architectures from Ghidra" ON)
option(BUILD_SLEIGH_PLUGIN "Build asm and analysis plugin to use sleigh as a disassembler in rizin" ON)
option(GENERATE_PARSERS "Re-generate all parsers with Bison/Flex instead of using pre-generated ones" OFF)
if (BUILD_CUTTER_PLUGIN)
find_package(Cutter REQUIRED)
set(CUTTER_INSTALL_PLUGDIR "${Cutter_USER_PLUGINDIR}" CACHE STRING "Directory to install Cutter plugin into")
endif()
if(CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_definitions(-std=c++11)
endif()
else()
set(CMAKE_CXX_STANDARD 11)
endif()
add_subdirectory(ghidra)
add_subdirectory(third-party)
set(PUBLIC_HEADERS
src/rz_ghidra.h)
set(CORE_SOURCE
src/core_ghidra.cpp
src/RizinArchitecture.cpp
src/RizinArchitecture.h
src/RizinLoadImage.cpp
src/RizinLoadImage.h
src/RizinScope.cpp
src/RizinScope.h
src/RizinTypeFactory.cpp
src/RizinTypeFactory.h
src/RizinCommentDatabase.cpp
src/RizinCommentDatabase.h
src/CodeXMLParse.h
src/CodeXMLParse.cpp
src/ArchMap.h
src/ArchMap.cpp
src/RizinPrintC.h
src/RizinPrintC.cpp
src/RzCoreMutex.h
src/RzCoreMutex.cpp
src/PrettyXmlEncode.h
src/PrettyXmlEncode.cpp
src/PcodeFixupPreprocessor.h
src/PcodeFixupPreprocessor.cpp
src/rz_ghidra.h
src/rz_ghidra_internal.h)
if(BUILD_SLEIGH_PLUGIN)
set(ASM_SOURCE
src/SleighAsm.h
src/SleighAsm.cpp
src/SleighInstruction.h
src/SleighInstruction.cpp
src/asm_ghidra.cpp)
set(ANALYSIS_SOURCE
src/SleighAsm.h
src/SleighAsm.cpp
src/SleighInstruction.h
src/SleighInstruction.cpp
src/SleighAnalysisValue.h
src/SleighAnalysisValue.cpp
src/analysis_ghidra.cpp)
endif()
add_library(core_ghidra SHARED ${CORE_SOURCE})
target_link_libraries(core_ghidra ghidra_libdecomp)
target_link_libraries(core_ghidra pugixml)
target_link_libraries(core_ghidra Rizin::Core)
set_target_properties(core_ghidra PROPERTIES
OUTPUT_NAME core_ghidra
PREFIX "")
configure_file(
${PROJECT_SOURCE_DIR}/rz_ghidra.pc.in
${PROJECT_BINARY_DIR}/rz_ghidra.pc
@ONLY)
if(BUILD_CUTTER_PLUGIN)
add_subdirectory(cutter-plugin)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
string (REPLACE ";" " " LD_RPATH_STR "@loader_path")
else()
string (REPLACE ";" " " LD_RPATH_STR "$ORIGIN")
endif()
if(BUILD_SLEIGH_PLUGIN)
add_library(asm_ghidra SHARED ${ASM_SOURCE})
target_link_libraries(asm_ghidra core_ghidra)
set_target_properties(asm_ghidra PROPERTIES
OUTPUT_NAME asm_ghidra
BUILD_RPATH "${LD_RPATH_STR}"
INSTALL_RPATH "${LD_RPATH_STR}"
PREFIX "")
add_library(analysis_ghidra SHARED ${ANALYSIS_SOURCE})
target_link_libraries(analysis_ghidra core_ghidra)
set_target_properties(analysis_ghidra PROPERTIES
OUTPUT_NAME analysis_ghidra
BUILD_RPATH "${LD_RPATH_STR}"
INSTALL_RPATH "${LD_RPATH_STR}"
PREFIX "")
endif()
if(SLEIGHHOME_DEFAULT)
target_compile_definitions(core_ghidra PRIVATE "-DRZ_GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
if(BUILD_SLEIGH_PLUGIN)
target_compile_definitions(asm_ghidra PRIVATE "-DRZ_GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
target_compile_definitions(analysis_ghidra PRIVATE "-DRZ_GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
endif()
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries.")
endif()
install(TARGETS core_ghidra DESTINATION "${RIZIN_INSTALL_PLUGDIR}")
if(BUILD_SLEIGH_PLUGIN)
install(TARGETS asm_ghidra DESTINATION "${RIZIN_INSTALL_PLUGDIR}")
install(TARGETS analysis_ghidra DESTINATION "${RIZIN_INSTALL_PLUGDIR}")
endif()
install(FILES ${PUBLIC_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rz_ghidra.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")