This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
155 lines (135 loc) · 4.8 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
144
145
146
147
148
149
150
151
152
153
154
155
# Tencent is pleased to support the open source community by making odbk available.
# Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://opensource.org/licenses/MIT
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
cmake_minimum_required(VERSION 2.8)
if ( WIN32 AND NOT CYGWIN AND NOT ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" ) AND NOT ANDROID)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT" CACHE STRING "")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" CACHE STRING "")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd" CACHE STRING "")
endif ()
project(odbk)
if ( IOS )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode")
endif ()
#option ( LUA_COMPAT_MODULE "compat module" ON)
find_path(ODBK_PROJECT_DIR NAMES SConstruct
PATHS
${CMAKE_SOURCE_DIR}
NO_DEFAULT_PATH
)
MARK_AS_ADVANCED(ODBK_PROJECT_DIR)
#set(LUA_SRC_PATH lua-5.3.5/src)
#set(LUAJIT_SRC_PATH luajit-2.1.0b3/src)
#begin yasio
if (NOT WIN32 OR CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if (ANDROID)
if (NOT THIRDPART_LIB)
set(THIRDPART_LIB "-llog")
else()
set(THIRDPART_LIB "${THIRDPART_LIB} -llog")
endif()
endif()
set (YASIO_SRC
yasio/yasio/ibstream.cpp
yasio/yasio/obstream.cpp
yasio/yasio/xxsocket.cpp
yasio/yasio/yasio.cpp
)
set_property(
SOURCE ${YASIO_SRC}
APPEND
PROPERTY COMPILE_DEFINITIONS
)
list(APPEND THIRDPART_INC yasio)
set (THIRDPART_SRC ${THIRDPART_SRC} ${YASIO_SRC})
#end yasio
#begin minhook
list(APPEND THIRDPART_INC "minhook/include")
#endf minhook
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${THIRDPART_INC}
)
if(WIN32)
LINK_DIRECTORIES(
"${CMAKE_SOURCE_DIR}\\minhook\\build\\VC15\\lib"
)
endif()
set ( ODBK_CORE
odbk/odbk_core.cpp
odbk/odbk_dbghelp.cpp
odbk/odbk_entry.cpp
odbk/odbk_hook.cpp
odbk/odbk_lhook.cpp
odbk/odbk_lload.cpp
odbk/odbk_utils.cpp
odbk/odbk_proto.cpp
)
macro(source_group_by_dir proj_dir source_files)
if(MSVC OR APPLE)
get_filename_component(sgbd_cur_dir ${proj_dir} ABSOLUTE)
foreach(sgbd_file ${${source_files}})
get_filename_component(sgbd_abs_file ${sgbd_file} ABSOLUTE)
file(RELATIVE_PATH sgbd_fpath ${sgbd_cur_dir} ${sgbd_abs_file})
string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
if(sgbd_nogroup)
set(sgbd_group_name "\\")
endif(sgbd_nogroup)
source_group(${sgbd_group_name} FILES ${sgbd_file})
endforeach(sgbd_file)
endif(MSVC OR APPLE)
endmacro(source_group_by_dir)
source_group_by_dir(${CMAKE_CURRENT_SOURCE_DIR} ODBK_CORE)
if (APPLE)
if (IOS)
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
add_library(odbk STATIC
${ODBK_CORE}
${THIRDPART_SRC}
)
set_xcode_property (odbk IPHONEOS_DEPLOYMENT_TARGET "7.0" "all")
else ()
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_64_BIT)")
add_library(odbk MODULE
${ODBK_CORE}
${THIRDPART_SRC}
)
set_target_properties ( odbk PROPERTIES BUNDLE TRUE )
#set_target_properties ( odbk PROPERTIES FRAMEWORK TRUE )
#set_target_properties ( odbk PROPERTIES MACOSX_RPATH TRUE )
endif ()
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Switch")
add_library(odbk STATIC
${ODBK_CORE}
${THIRDPART_SRC}
)
target_compile_options(odbk PRIVATE -m64 -mcpu=cortex-a57+fp+simd+crypto+crc -fno-common -fno-short-enums -ffunction-sections -fdata-sections -fPIC -fms-extensions)
else ( )
add_library(odbk SHARED
${ODBK_CORE}
${THIRDPART_SRC}
)
endif ( )
if(UINT_ESPECIALLY)
ADD_DEFINITIONS(-DUINT_ESPECIALLY)
endif()
if ( WIN32 AND NOT CYGWIN )
target_link_libraries(odbk
ws2_32
${THIRDPART_LIB}
)
else ( )
target_link_libraries(odbk
m
${THIRDPART_LIB}
)
endif ( )