forked from 0vercl0k/rp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (85 loc) · 2.84 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
# unix => cd build/ && cmake .. && make
cmake_minimum_required(VERSION 2.6)
project(rp++)
option (optX86BUILD "Generate an x86 executable" OFF)
set(CMAKE_BUILD_TYPE Release)
# set(CMAKE_BUILD_TYPE Debug)
set(EXECUTABLE_OUTPUT_PATH ../bin/)
set(RP_NAME "rp")
if(WIN32)
set(RP_PLAT "win")
set(EXTENSION_LIBRARY lib)
endif(WIN32)
if(UNIX)
if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
set(RP_PLAT "fbsd")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
set(RP_PLAT "osx")
else()
set(RP_PLAT "lin")
endif()
set(EXTENSION_LIBRARY a)
endif(UNIX)
if(FBSD)
set(RP_PLAT "fbsd")
set(EXTENSION_LIBRARY a)
endif(FBSD)
set(RP_NAME "${RP_NAME}-${RP_PLAT}")
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT(optX86BUILD))
set(FLAG_CXX "-m64")
set(RP_NAME "${RP_NAME}-x64")
set(BEA_LIBRARY "BeaEngine.x64.${RP_PLAT}.${EXTENSION_LIBRARY}")
set(ARGTABLE_LIBRARY "argtable2.x64.${RP_PLAT}.${EXTENSION_LIBRARY}")
else()
set(FLAG_CXX "-m32")
set(RP_NAME "${RP_NAME}-x86")
set(BEA_LIBRARY "BeaEngine.x86.${RP_PLAT}.${EXTENSION_LIBRARY}")
set(ARGTABLE_LIBRARY "argtable2.x86.${RP_PLAT}.${EXTENSION_LIBRARY}")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT(optX86BUILD))
if(MSVC)
# link the CRT
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
if(${flag_var} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MDd")
endforeach(flag_var)
endif(MSVC)
if(CMAKE_COMPILER_IS_GNUCXX)
# an optimized secure static striped binary !
# btw if you want a full secure binary, disable the -static option (with static you can have only partial relro & no cookie)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -static -s -Wl,-z,relro,-z,now -fstack-protector-all ${FLAG_CXX}")
endif(CMAKE_COMPILER_IS_GNUCXX)
include_directories("./src/inc/")
include_directories("./lib/beaengine/inc/")
include_directories("./lib/argtable2/inc/")
file(
GLOB_RECURSE
ropgadget_pp_files
./src/*
)
add_executable(
${RP_NAME}
${ropgadget_pp_files}
)
add_library(beaengine STATIC IMPORTED)
set_property(
TARGET beaengine PROPERTY
IMPORTED_LOCATION ../lib/beaengine/bin/${BEA_LIBRARY}
)
add_library(argtable2 STATIC IMPORTED)
set_property(
TARGET argtable2 PROPERTY
IMPORTED_LOCATION ../lib/argtable2/bin/${ARGTABLE_LIBRARY}
)
target_link_libraries(
${RP_NAME}
beaengine
argtable2
)
if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:crt64.lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:crt.lib")
endif(WIN32)