-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
CocosUsePrebuiltLibs.cmake
235 lines (200 loc) · 6.2 KB
/
CocosUsePrebuiltLibs.cmake
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# CocosUsePrebuiltLibs - sets external libs variables to link with
# START CONFIG
set(_chipmunk_inc chipmunk/chipmunk.h)
set(_chipmunk_inc_paths include)
if(WINDOWS)
if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
set(_chipmunk_libs chipmunk libchipmunk-2015)
else()
set(_chipmunk_libs chipmunk libchipmunk)
endif(${MSVC_VERSION})
else()
set(_chipmunk_libs chipmunk libchipmunk)
endif(WINDOWS)
set(_bullet_inc bullet/Bullet-C-Api.h BulletCollision/btBulletCollisionCommon.h)
set(_bullet_inc_paths bullet)
# sequence is important
set(_bullet_libs BulletDynamics libBulletDynamics BulletCollision libBulletCollision BulletMultiThreaded libBulletMultiThreaded LinearMath libLinearMath MiniCL libMiniCL)
set(_Box2D_inc Box2D/Box2D.h)
set(_Box2D_inc_paths include)
set(_Box2D_libs box2d libbox2d)
set(_Box2D_prefix Box2D)
set(_glfw3_inc glfw3.h glfw3native.h)
set(_glfw3_libs glfw3 libglfw3)
set(_curl_inc curl/curl.h)
# order: curl, ssl, crypto
set(_curl_libs curl libcurl_imp libcurl ssl libeay32 ssleay32 crypto)
set(_freetype2_prefix FREETYPE)
set(_freetype2_inc ft2build.h freetype/freetype.h)
set(_freetype2_inc_paths freetype2)
set(_freetype2_libs freetype freetype250)
set(_jpeg_inc jpeglib.h)
if(WINDOWS)
if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
set(_jpeg_libs jpeg libjpeg-2015)
else()
set(_jpeg_libs jpeg libjpeg)
endif(${MSVC_VERSION})
else()
set(_jpeg_libs jpeg libjpeg)
endif(WINDOWS)
set(_png_inc png.h)
if(WINDOWS)
if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
set(_png_libs png libpng-2015)
else()
set(_png_libs png libpng)
endif(${MSVC_VERSION})
else()
set(_png_libs png libpng)
endif(WINDOWS)
set(_tiff_inc tiff.h)
if(WINDOWS)
if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
set(_tiff_libs tiff libtiff-2015)
else()
set(_tiff_libs tiff libtiff)
endif(${MSVC_VERSION})
else()
set(_tiff_libs tiff libtiff)
endif(WINDOWS)
set(_webp_inc decode.h)
set(_webp_libs webp libwebp)
set(_websockets_inc libwebsockets.h)
set(_websockets_libs websockets libwebsockets)
set(_openssl_inc openssl/ssl.h)
set(_openssl_libs ssl crypto)
set(_glfw3_inc glfw3.h)
if(WINDOWS)
if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
set(_glfw3_libs glfw3-2015 libglfw3)
else()
set(_glfw3_libs glfw3 libglfw3)
endif(${MSVC_VERSION})
else()
set(_glfw3_libs glfw3 libglfw3)
endif(WINDOWS)
set(_sqlite3_inc sqlite3.h)
set(_sqlite3_libs sqlite3)
set(_gles_prefix GLEW)
set(_gles_inc GL/glew.h)
set(_gles_inc_paths OGLES)
set(_gles_libs glew32)
set(_icon_prefix ICONV)
set(_icon_inc iconv.h)
set(_icon_libs libiconv)
set(_MP3Decoder_prefix MPG123)
set(_MP3Decoder_inc mpg123.h)
set(_MP3Decoder_libs libmpg123)
set(_OggDecoder_prefix VORBIS)
set(_OggDecoder_inc ogg/ogg.h)
set(_OggDecoder_libs libogg libvorbis libvorbisfile)
set(_OpenalSoft_prefix OPENAL)
set(_OpenalSoft_inc al.h)
set(_OpenalSoft_inc_paths AL)
set(_OpenalSoft_libs OpenAL32)
set(_zlib_inc zlib.h)
set(_zlib_libs z libzlib libz)
set(_fmod_prefix FMOD)
set(_fmod_inc fmod.hpp)
set(_fmod_libs fmod fmod64 fmod fmod64)
set(all_prebuilt_libs
chipmunk
curl
freetype2
jpeg
png
tiff
webp
websockets
openssl
bullet
Box2D
)
if(MACOSX)
list(APPEND all_prebuilt_libs glfw3 zlib)
endif()
# We use MSVC instead of WINDOWS because it can be mingw that can't use our prebuilt libs
if(MSVC)
list(APPEND all_prebuilt_libs glfw3 sqlite3 gles icon MP3Decoder OggDecoder OpenalSoft zlib)
endif()
if(LINUX)
list(APPEND all_prebuilt_libs fmod glfw3)
endif()
if(ANDROID)
list(APPEND all_prebuilt_libs zlib)
endif()
# END CONFIG
foreach(_lib ${all_prebuilt_libs})
if(_${_lib}_prefix)
set(_prefix ${_${_lib}_prefix})
else()
# auto-prefix is uppercased name
string(TOUPPER ${_lib} _prefix)
endif()
set(roots
${COCOS_EXTERNAL_DIR}/${_lib}
${COCOS_EXTERNAL_DIR}/${PLATFORM_FOLDER}-specific/${_lib}
)
foreach(_root ${roots})
if(EXISTS ${_root})
set(include_dir_candidates
${_root}/include
${_root}/include/${ARCH_DIR}
${_root}/include/${PLATFORM_FOLDER}
${_root}/include/${PLATFORM_FOLDER}/${ARCH_DIR}
)
set(include_dirs)
foreach(_dir ${include_dir_candidates})
if(EXISTS ${_dir})
# find all include paths
if(_${_lib}_inc_paths)
set(_suffixes ${_${_lib}_inc_paths})
else()
set(_suffixes include)
endif()
foreach(_inc_name ${_${_lib}_inc})
unset(_inc_tmp CACHE)
find_path(_inc_tmp ${_inc_name} PATH_SUFFIXES ${_suffixes} PATHS ${_dir} NO_DEFAULT_PATH)
if(_inc_tmp)
list(APPEND include_dirs ${_inc_tmp})
endif()
endforeach()
endif(EXISTS ${_dir})
endforeach()
if(include_dirs)
set(${_prefix}_INCLUDE_DIRS ${include_dirs} CACHE PATH "Path to includes for ${_prefix}" FORCE)
endif()
#message(STATUS "${_lib} ${_prefix}_INCLUDE_DIRS: ${${_prefix}_INCLUDE_DIRS}")
set(lib_dir_candidates
${_root}/prebuilt/${PLATFORM_FOLDER}/${ANDROID_ABI}
${_root}/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
${_root}/prebuilt/${PLATFORM_FOLDER}
${_root}/prebuilt/${PLATFORM_FOLDER}/release-lib
${_root}/prebuilt/${ARCH_DIR}
${_root}/libraries/${PLATFORM_FOLDER}
${_root}/prebuilt
)
set(libs)
foreach(_dir ${lib_dir_candidates})
if(EXISTS ${_dir})
# find all libs
foreach(_lib_name ${_${_lib}_libs})
unset(_lib_tmp CACHE)
find_library(_lib_tmp ${_lib_name} PATHS ${_dir} NO_DEFAULT_PATH)
if(_lib_tmp)
list(APPEND libs ${_lib_tmp})
endif()
endforeach()
endif(EXISTS ${_dir})
endforeach()
if(libs)
set(${_prefix}_LIBRARIES ${libs} CACHE STRING "Libraries to link for ${_prefix}" FORCE)
endif()
message(STATUS "${_lib} ${_prefix}_LIBRARIES: ${${_prefix}_LIBRARIES}")
if(${_prefix}_LIBRARIES AND ${_prefix}_INCLUDE_DIRS)
set(${_prefix}_FOUND YES)
endif()
endif(EXISTS ${_root})
endforeach()
endforeach()