CocosUsePrebuiltLibs.cmake 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. # CocosUsePrebuiltLibs - sets external libs variables to link with
  2. # START CONFIG
  3. set(_chipmunk_inc chipmunk/chipmunk.h)
  4. set(_chipmunk_inc_paths include)
  5. if(WINDOWS)
  6. if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
  7. set(_chipmunk_libs chipmunk libchipmunk-2015)
  8. else()
  9. set(_chipmunk_libs chipmunk libchipmunk)
  10. endif(${MSVC_VERSION})
  11. else()
  12. set(_chipmunk_libs chipmunk libchipmunk)
  13. endif(WINDOWS)
  14. set(_bullet_inc bullet/Bullet-C-Api.h BulletCollision/btBulletCollisionCommon.h)
  15. set(_bullet_inc_paths bullet)
  16. # sequence is important
  17. set(_bullet_libs BulletDynamics libBulletDynamics BulletCollision libBulletCollision BulletMultiThreaded libBulletMultiThreaded LinearMath libLinearMath MiniCL libMiniCL)
  18. set(_curl_inc curl/curl.h)
  19. # order: curl, ssl, crypto
  20. set(_curl_libs curl libcurl_imp libcurl ssl libeay32 ssleay32 crypto)
  21. set(_freetype2_prefix FREETYPE)
  22. set(_freetype2_inc ft2build.h freetype/freetype.h)
  23. set(_freetype2_inc_paths freetype2)
  24. set(_freetype2_libs freetype freetype250)
  25. set(_jpeg_inc jpeglib.h)
  26. if(WINDOWS)
  27. if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
  28. set(_jpeg_libs jpeg libjpeg-2015)
  29. else()
  30. set(_jpeg_libs jpeg libjpeg)
  31. endif(${MSVC_VERSION})
  32. else()
  33. set(_jpeg_libs jpeg libjpeg)
  34. endif(WINDOWS)
  35. set(_png_inc png.h)
  36. if(WINDOWS)
  37. if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
  38. set(_png_libs png libpng-2015)
  39. else()
  40. set(_png_libs png libpng)
  41. endif(${MSVC_VERSION})
  42. else()
  43. set(_png_libs png libpng)
  44. endif(WINDOWS)
  45. set(_tiff_inc tiff.h)
  46. if(WINDOWS)
  47. if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
  48. set(_tiff_libs tiff libtiff-2015)
  49. else()
  50. set(_tiff_libs tiff libtiff)
  51. endif(${MSVC_VERSION})
  52. else()
  53. set(_tiff_libs tiff libtiff)
  54. endif(WINDOWS)
  55. set(_webp_inc decode.h)
  56. set(_webp_libs webp libwebp)
  57. set(_websockets_inc libwebsockets.h)
  58. set(_websockets_libs websockets libwebsockets)
  59. set(_openssl_inc openssl/ssl.h)
  60. set(_openssl_libs ssl crypto)
  61. set(_glfw3_inc glfw3.h)
  62. if(WINDOWS)
  63. if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
  64. set(_glfw3_libs glfw3-2015 libglfw3)
  65. else()
  66. set(_glfw3_libs glfw3 libglfw3)
  67. endif(${MSVC_VERSION})
  68. else()
  69. set(_glfw3_libs glfw3 libglfw3)
  70. endif(WINDOWS)
  71. set(_sqlite3_inc sqlite3.h)
  72. set(_sqlite3_libs sqlite3)
  73. set(_gles_prefix GLEW)
  74. set(_gles_inc GL/glew.h)
  75. set(_gles_inc_paths OGLES)
  76. set(_gles_libs glew32)
  77. set(_icon_prefix ICONV)
  78. set(_icon_inc iconv.h)
  79. set(_icon_libs libiconv)
  80. set(_MP3Decoder_prefix MPG123)
  81. set(_MP3Decoder_inc mpg123.h)
  82. set(_MP3Decoder_libs libmpg123)
  83. set(_OggDecoder_prefix VORBIS)
  84. set(_OggDecoder_inc ogg/ogg.h)
  85. set(_OggDecoder_libs libogg libvorbis libvorbisfile)
  86. set(_OpenalSoft_prefix OPENAL)
  87. set(_OpenalSoft_inc al.h)
  88. set(_OpenalSoft_inc_paths AL)
  89. set(_OpenalSoft_libs OpenAL32)
  90. set(_zlib_inc zlib.h)
  91. set(_zlib_libs z libzlib libz)
  92. set(_fmod_prefix FMOD)
  93. set(_fmod_inc fmod.hpp)
  94. set(_fmod_libs fmod fmod64 fmod fmod64)
  95. set(all_prebuilt_libs
  96. chipmunk
  97. curl
  98. freetype2
  99. jpeg
  100. png
  101. tiff
  102. webp
  103. websockets
  104. openssl
  105. bullet
  106. )
  107. if(MACOSX)
  108. list(APPEND all_prebuilt_libs glfw3 zlib)
  109. endif()
  110. # We use MSVC instead of WINDOWS because it can be mingw that can't use our prebuilt libs
  111. if(MSVC)
  112. list(APPEND all_prebuilt_libs glfw3 sqlite3 gles icon MP3Decoder OggDecoder OpenalSoft zlib)
  113. endif()
  114. if(LINUX)
  115. list(APPEND all_prebuilt_libs fmod)
  116. endif()
  117. if(ANDROID)
  118. list(APPEND all_prebuilt_libs zlib)
  119. endif()
  120. # END CONFIG
  121. foreach(_lib ${all_prebuilt_libs})
  122. if(_${_lib}_prefix)
  123. set(_prefix ${_${_lib}_prefix})
  124. else()
  125. # auto-prefix is uppercased name
  126. string(TOUPPER ${_lib} _prefix)
  127. endif()
  128. set(roots
  129. ${COCOS_EXTERNAL_DIR}/${_lib}
  130. ${COCOS_EXTERNAL_DIR}/${PLATFORM_FOLDER}-specific/${_lib}
  131. )
  132. foreach(_root ${roots})
  133. if(EXISTS ${_root})
  134. set(include_dir_candidates
  135. ${_root}/include
  136. ${_root}/include/${ARCH_DIR}
  137. ${_root}/include/${PLATFORM_FOLDER}
  138. ${_root}/include/${PLATFORM_FOLDER}/${ARCH_DIR}
  139. )
  140. set(include_dirs)
  141. foreach(_dir ${include_dir_candidates})
  142. if(EXISTS ${_dir})
  143. # find all include paths
  144. if(_${_lib}_inc_paths)
  145. set(_suffixes ${_${_lib}_inc_paths})
  146. else()
  147. set(_suffixes include)
  148. endif()
  149. foreach(_inc_name ${_${_lib}_inc})
  150. unset(_inc_tmp CACHE)
  151. find_path(_inc_tmp ${_inc_name} PATH_SUFFIXES ${_suffixes} PATHS ${_dir} NO_DEFAULT_PATH)
  152. if(_inc_tmp)
  153. list(APPEND include_dirs ${_inc_tmp})
  154. endif()
  155. endforeach()
  156. endif(EXISTS ${_dir})
  157. endforeach()
  158. if(include_dirs)
  159. set(${_prefix}_INCLUDE_DIRS ${include_dirs} CACHE PATH "Path to includes for ${_prefix}" FORCE)
  160. endif()
  161. #message(STATUS "${_lib} ${_prefix}_INCLUDE_DIRS: ${${_prefix}_INCLUDE_DIRS}")
  162. set(lib_dir_candidates
  163. ${_root}/prebuilt/${PLATFORM_FOLDER}/${ANDROID_ABI}
  164. ${_root}/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
  165. ${_root}/prebuilt/${PLATFORM_FOLDER}
  166. ${_root}/prebuilt/${PLATFORM_FOLDER}/release-lib
  167. ${_root}/prebuilt/${ARCH_DIR}
  168. ${_root}/libraries/${PLATFORM_FOLDER}
  169. ${_root}/prebuilt
  170. )
  171. set(libs)
  172. foreach(_dir ${lib_dir_candidates})
  173. if(EXISTS ${_dir})
  174. # find all libs
  175. foreach(_lib_name ${_${_lib}_libs})
  176. unset(_lib_tmp CACHE)
  177. find_library(_lib_tmp ${_lib_name} PATHS ${_dir} NO_DEFAULT_PATH)
  178. if(_lib_tmp)
  179. list(APPEND libs ${_lib_tmp})
  180. endif()
  181. endforeach()
  182. endif(EXISTS ${_dir})
  183. endforeach()
  184. if(libs)
  185. set(${_prefix}_LIBRARIES ${libs} CACHE STRING "Libraries to link for ${_prefix}" FORCE)
  186. endif()
  187. message(STATUS "${_lib} ${_prefix}_LIBRARIES: ${${_prefix}_LIBRARIES}")
  188. if(${_prefix}_LIBRARIES AND ${_prefix}_INCLUDE_DIRS)
  189. set(${_prefix}_FOUND YES)
  190. endif()
  191. endif(EXISTS ${_root})
  192. endforeach()
  193. endforeach()