forked from cocos2d/cocos2d-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
198 lines (168 loc) · 5.98 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#/****************************************************************************
# Copyright (c) 2013 cocos2d-x.org
# Copyright (c) 2014 martell malone
# Copyright (c) 2015-2017 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
# 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.
# ****************************************************************************/
# this CMakeLists is to generate libcocos2d.a
cmake_minimum_required(VERSION 3.1)
if(WINDOWS)
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
endif()
include(2d/CMakeLists.txt)
include(3d/CMakeLists.txt)
include(platform/CMakeLists.txt)
include(physics/CMakeLists.txt)
include(physics3d/CMakeLists.txt)
include(math/CMakeLists.txt)
include(navmesh/CMakeLists.txt)
include(renderer/CMakeLists.txt)
include(vr/CMakeLists.txt)
include(base/CMakeLists.txt)
include(deprecated/CMakeLists.txt)
include(ui/CMakeLists.txt)
include(network/CMakeLists.txt)
include(audio/CMakeLists.txt)
include(storage/CMakeLists.txt)
if(BUILD_EDITOR_COCOSBUILDER)
include(editor-support/cocosbuilder/CMakeLists.txt)
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CCB_SRC})
endif(BUILD_EDITOR_COCOSBUILDER)
if(BUILD_EDITOR_COCOSTUDIO)
include(editor-support/cocostudio/CMakeLists.txt)
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CS_SRC})
endif(BUILD_EDITOR_COCOSTUDIO)
if(BUILD_EDITOR_SPINE)
include(editor-support/spine/CMakeLists.txt)
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_SPINE_SRC})
endif(BUILD_EDITOR_SPINE)
include(../extensions/CMakeLists.txt)
set(COCOS_SRC cocos2d.cpp
${COCOS_2D_SRC}
${COCOS_3D_SRC}
${COCOS_PLATFORM_SRC}
${COCOS_PHYSICS_SRC}
${COCOS_PHYSICS3D_SRC}
${COCOS_MATH_SRC}
${COCOS_NAVMESH_SRC}
${COCOS_RENDERER_SRC}
${COCOS_VR_SRC}
${COCOS_BASE_SRC}
${COCOS_AUDIO_SRC}
${COCOS_UI_SRC}
${COCOS_DEPRECATED_SRC}
${COCOS_NETWORK_SRC}
${COCOS_EDITOR_SUPPORT_SRC}
${COCOS_EXTENSIONS_SRC}
)
#todo: provide prebuild versions of the xx libs for all platforms
include_directories(../external/xxtea)
include_directories(../external/clipper)
add_library(cocos2dInternal ${COCOS_SRC})
set_target_properties(cocos2dInternal
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
VERSION "${COCOS2D_X_VERSION}"
)
set(PLATFORM_SPECIFIC_LIBS)
if(WINDOWS)
foreach(_pkg OPENGL GLEW GLFW3 VORBIS MPG123 OPENAL)
cocos_use_pkg(cocos2dInternal ${_pkg})
endforeach()
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm version)
if(MINGW)
list(APPEND PLATFORM_SPECIFIC_LIBS shlwapi version)
endif()
elseif(LINUX)
foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3)
cocos_use_pkg(cocos2dInternal ${_pkg})
endforeach()
elseif(MACOSX OR APPLE)
cocos_use_pkg(cocos2dInternal GLFW3)
INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(OPENGL_LIBRARY OpenGL )
FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox)
FIND_LIBRARY(OPENAL_LIBRARY OpenAL )
FIND_LIBRARY(QUARTZCORE_LIBRARY QuartzCore )
FIND_LIBRARY(APPLICATIONSERVICES_LIBRARY ApplicationServices)
FIND_LIBRARY(IOKIT_LIBRARY IOKit)
FIND_LIBRARY(FOUNDATION_LIBRARY Foundation)
FIND_LIBRARY(ICONV_LIBRARY iconv)
set(PLATFORM_SPECIFIC_LIBS
${COCOA_LIBRARY}
${OPENGL_LIBRARY}
${OPENAL_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${QUARTZCORE_LIBRARY}
${APPLICATIONSERVICES_LIBRARY}
${IOKIT_LIBRARY}
${FOUNDATION_LIBRARY}
${ICONV_LIBRARY}
)
elseif(ANDROID)
set(PLATFORM_SPECIFIC_LIBS GLESv1_CM GLESv2 EGL log android OpenSLES)
get_filename_component(__module_path "${CMAKE_TOOLCHAIN_FILE}" DIRECTORY)
include(${__module_path}/AndroidNdkModules.cmake)
android_ndk_import_module_cpufeatures()
else()
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
endif()
foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL OPENSSL FLATBUFFERS XXHASH)
cocos_use_pkg(cocos2dInternal ${pkg})
endforeach()
if(LINUX)
set(glfw_other_linker_flags X11)
endif(LINUX)
target_link_libraries(cocos2dInternal ${PLATFORM_SPECIFIC_LIBS} ${glfw_other_linker_flags})
if(USE_WEBP)
add_definitions(-DCC_USE_WEBP=1)
cocos_use_pkg(cocos2dInternal WEBP)
else()
add_definitions(-DCC_USE_WEBP=0)
endif()
if(USE_CHIPMUNK)
cocos_use_pkg(cocos2dInternal CHIPMUNK)
endif()
if(USE_BOX2D)
cocos_use_pkg(cocos2dInternal Box2D)
endif()
if(USE_BULLET)
cocos_use_pkg(cocos2dInternal BULLET)
endif()
if(USE_RECAST)
cocos_use_pkg(cocos2dInternal RECAST)
endif()
ADD_LIBRARY(cocos2d cc_dummy.c)
if(ANDROID)
target_link_libraries(cocos2d -Wl,-whole-archive cocos2dxandroid_static -Wl,-no-whole-archive)
target_link_libraries(cocos2d cocos2dInternal cpufeatures)
elseif(LINUX)
target_link_libraries(cocos2d cocos2dInternal dl)
else()
target_link_libraries(cocos2d cocos2dInternal)
endif()
set_target_properties(cocos2d
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
VERSION "${COCOS2D_X_VERSION}"
)