CMakeLists.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #/****************************************************************************
  2. # Copyright (c) 2013-2014 cocos2d-x.org
  3. # Copyright (c) 2015-2017 Chukong Technologies Inc.
  4. #
  5. # http://www.cocos2d-x.org
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. # ****************************************************************************/
  23. cmake_minimum_required(VERSION 3.6)
  24. set(APP_NAME spine-cocos2dx-example)
  25. project(${APP_NAME})
  26. set(BUILD_EXTENSIONS OFF CACHE BOOL "Build extensions" FORCE)
  27. include(../spine-cocos2dx.cmake)
  28. if(XCODE)
  29. if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
  30. SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0)
  31. endif()
  32. endif()
  33. if(NOT DEFINED BUILD_ENGINE_DONE) # to test spine-cocos2dx-example into root project
  34. set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
  35. set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)
  36. include(CocosBuildSet)
  37. add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
  38. endif()
  39. # record sources, headers, resources...
  40. set(GAME_RES_FOLDER
  41. "${CMAKE_CURRENT_SOURCE_DIR}/Resources"
  42. )
  43. if(APPLE OR WINDOWS)
  44. cocos_mark_multi_resources(common_res_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
  45. endif()
  46. # add cross-platforms source files and header files
  47. file(GLOB_RECURSE GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/Classes/*.cpp")
  48. file(GLOB_RECURSE GAME_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/Classes/*.h")
  49. set(GAME_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/Classes")
  50. if(ANDROID)
  51. # change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
  52. set(APP_NAME MyGame)
  53. list(APPEND GAME_SOURCE
  54. proj.android/app/jni/hellocpp/main.cpp
  55. )
  56. elseif(LINUX)
  57. list(APPEND GAME_SOURCE
  58. proj.linux/main.cpp
  59. )
  60. elseif(WINDOWS)
  61. list(APPEND GAME_HEADER
  62. proj.win32/main.h
  63. proj.win32/resource.h
  64. )
  65. list(APPEND GAME_SOURCE
  66. proj.win32/main.cpp
  67. proj.win32/game.rc
  68. ${common_res_files}
  69. )
  70. elseif(APPLE)
  71. if(IOS)
  72. list(APPEND GAME_HEADER
  73. proj.ios_mac/ios/AppController.h
  74. proj.ios_mac/ios/RootViewController.h
  75. )
  76. set(APP_UI_RES
  77. proj.ios_mac/ios/LaunchScreen.storyboard
  78. proj.ios_mac/ios/LaunchScreenBackground.png
  79. proj.ios_mac/ios/Images.xcassets
  80. )
  81. list(APPEND GAME_SOURCE
  82. proj.ios_mac/ios/main.m
  83. proj.ios_mac/ios/AppController.mm
  84. proj.ios_mac/ios/RootViewController.mm
  85. proj.ios_mac/ios/Prefix.pch
  86. ${APP_UI_RES}
  87. )
  88. elseif(MACOSX)
  89. set(APP_UI_RES
  90. proj.ios_mac/mac/Icon.icns
  91. proj.ios_mac/mac/Info.plist
  92. )
  93. list(APPEND GAME_SOURCE
  94. proj.ios_mac/mac/main.cpp
  95. proj.ios_mac/mac/Prefix.pch
  96. ${APP_UI_RES}
  97. )
  98. endif()
  99. list(APPEND GAME_SOURCE ${common_res_files})
  100. endif()
  101. # mark app complie info and libs info
  102. set(all_code_files
  103. ${GAME_HEADER}
  104. ${GAME_SOURCE}
  105. )
  106. if(NOT ANDROID)
  107. add_executable(${APP_NAME} ${all_code_files})
  108. else()
  109. add_library(${APP_NAME} SHARED ${all_code_files})
  110. add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
  111. target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
  112. endif()
  113. # Link the spine-cpp and spine-cocos2dx library to the app
  114. target_link_libraries(${APP_NAME} spine-cpp spine-cocos2dx)
  115. target_link_libraries(${APP_NAME} cocos2d)
  116. target_include_directories(${APP_NAME}
  117. PRIVATE ${GAME_INCLUDE}
  118. PRIVATE ${COCOS2DX_ROOT_PATH}/cocos/audio/include/
  119. )
  120. # mark app resources
  121. setup_cocos_app_config(${APP_NAME})
  122. if(APPLE)
  123. set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
  124. if(MACOSX)
  125. set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist")
  126. elseif(IOS)
  127. set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist")
  128. set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
  129. endif()
  130. # For code-signing, set the DEVELOPMENT_TEAM:
  131. #set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")
  132. elseif(WINDOWS)
  133. cocos_copy_target_dll(${APP_NAME})
  134. endif()
  135. if(LINUX OR WINDOWS)
  136. cocos_get_resource_path(APP_RES_DIR ${APP_NAME})
  137. cocos_copy_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
  138. endif()