forked from rizinorg/rz-ghidra
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
96 lines (81 loc) · 2.81 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
cmake_minimum_required(VERSION 3.0)
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
project(r2ghidra)
set(RADARE2_INSTALL_PLUGDIR "share/radare2/plugins" CACHE PATH "Directory to install radare2 plugin into")
set(CUTTER_INSTALL_PLUGDIR "share/RadareOrg/Cutter/plugins/native" CACHE PATH "Directory to install Cutter plugin into")
set(CUTTER_SOURCE_DIR CUTTER_SOURCE_DIR-NOTFOUND CACHE STRING "Root directory of Cutter source")
option(BUILD_CUTTER_PLUGIN "Build r2ghidra plugin for Cutter" OFF)
option(BUILD_DECOMPILE_EXECUTABLE "Build \"decompile\" executable as used by Ghidra (not needed for r2)" OFF)
option(BUILD_DECOMPILE_CLI_EXECUTABLE "Build REPL decompiler (not needed for r2)" OFF)
option(BUILD_SLASPECS "Build Sleigh specs for architectures from Ghidra" ON)
option(BUILD_SLEIGH_PLUGIN "Build asm plugin to use sleigh as a disassembler in r2" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
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(CORE_SOURCE
src/core_ghidra.cpp
src/R2Architecture.cpp
src/R2Architecture.h
src/R2LoadImage.cpp
src/R2LoadImage.h
src/R2Scope.cpp
src/R2Scope.h
src/R2TypeFactory.cpp
src/R2TypeFactory.h
src/R2CommentDatabase.cpp
src/R2CommentDatabase.h
src/CodeXMLParse.h
src/CodeXMLParse.cpp
src/ArchMap.h
src/ArchMap.cpp
src/R2PrintC.h
src/R2PrintC.cpp
src/R2PrintLLVM.h
src/R2PrintLLVM.cpp
src/printLLVM.cc
src/printLLVM.hh
src/RCoreMutex.h
src/RCoreMutex.cpp)
if(BUILD_SLEIGH_PLUGIN)
set(ASM_SOURCE
src/SleighAsm.h
src/SleighAsm.cpp
src/asm_ghidra.cpp)
endif()
find_package(Radare2 REQUIRED)
if(BUILD_CUTTER_PLUGIN)
add_subdirectory(cutter-plugin)
endif()
add_library(core_ghidra SHARED ${CORE_SOURCE})
target_link_libraries(core_ghidra ghidra_decompiler_base ghidra_libdecomp ghidra_decompiler_sleigh)
target_link_libraries(core_ghidra pugixml)
target_link_libraries(core_ghidra Radare2::libr)
set_target_properties(core_ghidra PROPERTIES
OUTPUT_NAME core_ghidra
PREFIX "")
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 "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
PREFIX "")
endif()
if(SLEIGHHOME_DEFAULT)
target_compile_definitions(core_ghidra PRIVATE "-DR2GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
if(BUILD_SLEIGH_PLUGIN)
target_compile_definitions(asm_ghidra PRIVATE "-DR2GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
endif()
endif()
install(TARGETS core_ghidra DESTINATION "${RADARE2_INSTALL_PLUGDIR}")
if(BUILD_SLEIGH_PLUGIN)
install(TARGETS asm_ghidra DESTINATION "${RADARE2_INSTALL_PLUGDIR}")
endif()