CocosUsePrebuiltLibs.cmake 5.6 KB

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