CMakeLists.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #/****************************************************************************
  2. # Copyright (c) 2013 cocos2d-x.org
  3. # Copyright (c) 2014 martell malone
  4. # Copyright (c) 2015-2017 Chukong Technologies Inc.
  5. #
  6. # http://www.cocos2d-x.org
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy
  9. # of this software and associated documentation files (the "Software"), to deal
  10. # in the Software without restriction, including without limitation the rights
  11. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. # copies of the Software, and to permit persons to whom the Software is
  13. # furnished to do so, subject to the following conditions:
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. # THE SOFTWARE.
  23. # ****************************************************************************/
  24. # this CMakeLists is to generate Cocos2d-x Engine Library
  25. # build libcocos2d
  26. # build luacocos2d if BUILD_LUA_LIBS=ON
  27. # build jscocos2d if BUILD_JS_LIBS=ON
  28. # The version number
  29. set(COCOS2D_X_VERSION 3.17)
  30. set(COCOS_CORE_LIB cocos2d)
  31. if(WINDOWS)
  32. add_definitions(-DUNICODE -D_UNICODE)
  33. endif()
  34. include(2d/CMakeLists.txt)
  35. include(3d/CMakeLists.txt)
  36. include(platform/CMakeLists.txt)
  37. include(physics/CMakeLists.txt)
  38. include(physics3d/CMakeLists.txt)
  39. include(math/CMakeLists.txt)
  40. include(navmesh/CMakeLists.txt)
  41. include(renderer/CMakeLists.txt)
  42. include(vr/CMakeLists.txt)
  43. include(base/CMakeLists.txt)
  44. include(deprecated/CMakeLists.txt)
  45. include(ui/CMakeLists.txt)
  46. include(network/CMakeLists.txt)
  47. include(audio/CMakeLists.txt)
  48. include(storage/CMakeLists.txt)
  49. if(BUILD_EDITOR_COCOSBUILDER)
  50. include(editor-support/cocosbuilder/CMakeLists.txt)
  51. set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CCB_SRC} ${COCOS_CCB_HEADER})
  52. endif(BUILD_EDITOR_COCOSBUILDER)
  53. if(BUILD_EDITOR_COCOSTUDIO)
  54. include(editor-support/cocostudio/CMakeLists.txt)
  55. set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CS_SRC} ${COCOS_CS_HEADER})
  56. endif(BUILD_EDITOR_COCOSTUDIO)
  57. if(BUILD_EDITOR_SPINE)
  58. include(editor-support/spine/CMakeLists.txt)
  59. set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_SPINE_SRC} ${COCOS_SPINE_HEADER})
  60. endif(BUILD_EDITOR_SPINE)
  61. if(BUILD_EXTENSIONS)
  62. include(../extensions/CMakeLists.txt)
  63. endif(BUILD_EXTENSIONS)
  64. set(COCOS_HEADER cocos2d.h
  65. ${COCOS_2D_HEADER}
  66. ${COCOS_3D_HEADER}
  67. ${COCOS_PLATFORM_HEADER}
  68. ${COCOS_PHYSICS_HEADER}
  69. ${COCOS_PHYSICS3D_HEADER}
  70. ${COCOS_MATH_HEADER}
  71. ${COCOS_NAVMESH_HEADER}
  72. ${COCOS_RENDERER_HEADER}
  73. ${COCOS_VR_HEADER}
  74. ${COCOS_BASE_HEADER}
  75. ${COCOS_AUDIO_HEADER}
  76. ${COCOS_UI_HEADER}
  77. ${COCOS_DEPRECATED_HEADER}
  78. ${COCOS_NETWORK_HEADER}
  79. ${COCOS_EDITOR_SUPPORT_HEADER}
  80. ${COCOS_EXTENSIONS_HEADER}
  81. ${COCOS_STORAGE_HEADER}
  82. )
  83. set(COCOS_SRC cocos2d.cpp
  84. ${COCOS_2D_SRC}
  85. ${COCOS_3D_SRC}
  86. ${COCOS_PLATFORM_SRC}
  87. ${COCOS_PHYSICS_SRC}
  88. ${COCOS_PHYSICS3D_SRC}
  89. ${COCOS_MATH_SRC}
  90. ${COCOS_NAVMESH_SRC}
  91. ${COCOS_RENDERER_SRC}
  92. ${COCOS_VR_SRC}
  93. ${COCOS_BASE_SRC}
  94. ${COCOS_AUDIO_SRC}
  95. ${COCOS_UI_SRC}
  96. ${COCOS_DEPRECATED_SRC}
  97. ${COCOS_NETWORK_SRC}
  98. ${COCOS_EDITOR_SUPPORT_SRC}
  99. ${COCOS_EXTENSIONS_SRC}
  100. ${COCOS_STORAGE_SRC}
  101. )
  102. #todo: provide prebuild versions of the xx libs for all platforms
  103. include_directories(../external/xxtea)
  104. include_directories(../external/clipper)
  105. list(APPEND COCOS_SRC ${COCOS_HEADER})
  106. add_library(cocos2d ${COCOS_SRC})
  107. # use necessary external libs and system libs
  108. include(CocosUseLibs)
  109. target_use_cocos2d_depend_libs(cocos2d)
  110. set_target_properties(cocos2d
  111. PROPERTIES
  112. ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
  113. LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
  114. VERSION "${COCOS2D_X_VERSION}"
  115. FOLDER "Internal"
  116. )
  117. # set custom target: prebuilt, to copy all libs to prebuilt libs folder
  118. if(GEN_COCOS_PREBUILT)
  119. add_custom_target(prebuilt ALL)
  120. add_dependencies(prebuilt cocos2d)
  121. set_target_properties(prebuilt
  122. PROPERTIES
  123. FOLDER "Internal"
  124. )
  125. add_custom_command(TARGET "prebuilt"
  126. POST_BUILD
  127. COMMAND ${CMAKE_COMMAND} -E copy_directory
  128. "${CMAKE_BINARY_DIR}/lib"
  129. "${COCOS_PREBUILT_PATH}"
  130. COMMENT "copy library directory:${CMAKE_BINARY_DIR}/lib to directory:${COCOS_PREBUILT_PATH}"
  131. )
  132. if(BUILD_LUA_LIBS)
  133. add_dependencies(prebuilt luacocos2d)
  134. endif()
  135. if(BUILD_JS_LIBS)
  136. add_dependencies(prebuilt jscocos2d)
  137. endif()
  138. if(BUILD_SIMU_LIB AND (MACOSX OR WINDOWS))
  139. add_dependencies(prebuilt simulator)
  140. endif()
  141. endif()
  142. ## Lua bindings lib
  143. if(BUILD_LUA_LIBS)
  144. add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/scripting/lua-bindings ${ENGINE_BINARY_PATH}/cocos/lua-bindings)
  145. endif()
  146. ## JS bindings lib
  147. if(BUILD_JS_LIBS)
  148. add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/scripting/js-bindings ${ENGINE_BINARY_PATH}/cocos/js-bindings)
  149. endif()
  150. # simulator
  151. if(BUILD_SIMU_LIB AND (MACOSX OR WINDOWS))
  152. add_subdirectory(${COCOS2DX_ROOT_PATH}/tools/simulator/libsimulator ${ENGINE_BINARY_PATH}/cocos/libsimulator)
  153. endif()
  154. if(XCODE OR VS)
  155. cocos_mark_code_files("cocos2d")
  156. endif()