forked from enty8080/Pwny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
136 lines (111 loc) · 5.16 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
#
# MIT License
#
# Copyright (c) 2020-2024 EntySec
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
cmake_minimum_required(VERSION 3.5.0)
project(libpwny VERSION 1.0.0)
option(DEBUG "Build in debug mode" OFF)
option(MAIN "Build main executable" OFF)
option(BUNDLE "Build as bundle (macOS/iOS)" OFF)
option(SHARED "Build shared object instead" OFF)
set(SOURCE src/main/main.c CACHE STRING "File to build as executable")
if (DEBUG)
add_compile_definitions(DEBUG)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
include_directories(include/compat include/mingw)
file(GLOB PWNY_SOURCES src/*.c src/compat/*.c src/mingw/*.c)
add_compile_definitions(__windows__)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
include_directories(include/posix)
file(GLOB PWNY_SOURCES src/*.c src/posix/*.c)
add_compile_definitions(__macintosh__)
if(BUNDLE)
add_link_options(-bundle)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
include_directories(include/posix)
file(GLOB PWNY_SOURCES src/*.c src/posix/*.c)
add_compile_definitions(__iphone__)
if(BUNDLE)
add_compile_definitions(IS_BUNDLE)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
include_directories(include/posix)
file(GLOB PWNY_SOURCES src/*.c src/posix/*.c)
add_compile_definitions(__linux__)
endif()
add_library(pwny STATIC ${PWNY_SOURCES})
set_property(TARGET pwny PROPERTY C_STANDART 99)
set_property(TARGET pwny PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(pwny PROPERTIES OUTPUT_NAME pwny)
include_directories(include api deps/build/${CMAKE_SYSTEM_TARGET}/include)
if(MAIN)
file(GLOB MAIN_SOURCES ${SOURCE})
add_executable(main ${MAIN_SOURCES})
target_link_directories(main PRIVATE deps/build/${CMAKE_SYSTEM_TARGET}/lib)
target_link_libraries(main PRIVATE pwny mbedtls mbedx509 mbedcrypto ev eio sigar)
if(NOT CMAKE_SYSTEM_NAME STREQUAL iOS)
target_link_libraries(main PRIVATE pawn injector)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_link_libraries(main PRIVATE injector pawn)
target_link_libraries(main PRIVATE ws2_32 netapi32 version)
target_link_options(main PRIVATE --static)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_compile_options(main PRIVATE -fobjc-arc)
target_link_libraries(main PRIVATE "-framework Foundation"
"-framework IOKit"
"-framework AVFoundation"
"-framework AppKit"
"-framework CoreMedia"
"-framework CoreImage")
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
target_link_libraries(main PRIVATE "-framework Foundation"
"-framework UIKitCore"
"-framework AVFCapture"
"-framework AVFCore"
"-framework AVFAudio"
"-framework CoreMedia"
"-framework CoreVideo"
"-framework CoreGraphics"
"-framework CoreImage"
"-framework BackBoardServices"
"-framework MediaRemote"
"-framework MediaPlayer"
"-framework SpringBoardServices"
"-framework CoreLocation"
"MobileGestalt")
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(SHARED)
target_link_options(main PRIVATE -shared -fPIC)
else()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x64)
target_link_options(main PRIVATE -static-pie -Wl,-z,max-page-size=4096)
else()
target_link_options(main PRIVATE -static-pie)
endif()
endif()
endif()
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})