CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. cmake_minimum_required(VERSION 3.1)
  25. # It ensures that when Find*.cmake files included from cmake's Modules dir
  26. # include another *.cmake file with relative path, that file will be included
  27. # also from cmake's Modules dir, to not clash with per-project files.
  28. cmake_policy(SET CMP0017 NEW)
  29. # Use new behaviour with cmake >= 3.1:
  30. # Only interpret if() arguments as variables or keywords when unquoted.
  31. if(CMAKE_VERSION VERSION_GREATER 3.1)
  32. cmake_policy(SET CMP0054 NEW)
  33. endif()
  34. project (Cocos2d-X)
  35. # The version number
  36. set(COCOS2D_X_VERSION 3.13)
  37. # define some variables
  38. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
  39. set(COCOS_EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
  40. # architecture
  41. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  42. set(ARCH_DIR "64-bit")
  43. elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
  44. set(ARCH_DIR "32-bit")
  45. else()
  46. message(FATAL_ERROR "Unsupported architecture, CMake will exit")
  47. return()
  48. endif()
  49. # CMAKE_BUILD_TYPE has precedence over DEBUG_MODE
  50. # Still supporting DEBUG_MODE for backwards compatibility
  51. if (NOT CMAKE_BUILD_TYPE)
  52. if(DEBUG_MODE)
  53. set(CMAKE_BUILD_TYPE DEBUG)
  54. else(DEBUG_MODE)
  55. set(CMAKE_BUILD_TYPE RELEASE)
  56. endif(DEBUG_MODE)
  57. endif(NOT CMAKE_BUILD_TYPE)
  58. include(CocosBuildHelpers)
  59. message(${BUILDING_STRING})
  60. # SelectModule() is a macro to select building modules
  61. include(SelectModule)
  62. SelectModule()
  63. # set compiler options
  64. include(SetCompilerOptions)
  65. SetCompilerOptions()
  66. if (CMAKE_FIND_ROOT_PATH AND USE_PREBUILT_LIBS)
  67. # Adds cocos2d-x external folder to the list of valid include/library paths when cross-compiling and using prebuilds
  68. set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR})
  69. endif ()
  70. include_directories(
  71. ${CMAKE_CURRENT_SOURCE_DIR}
  72. ${CMAKE_CURRENT_SOURCE_DIR}/cocos
  73. ${CMAKE_CURRENT_SOURCE_DIR}/deprecated
  74. ${CMAKE_CURRENT_SOURCE_DIR}/cocos/platform
  75. ${CMAKE_CURRENT_SOURCE_DIR}/extensions
  76. ${CMAKE_CURRENT_SOURCE_DIR}/external
  77. )
  78. if(USE_PREBUILT_LIBS)
  79. include(CocosUsePrebuiltLibs)
  80. endif()
  81. include(BuildModules)
  82. BuildModules()
  83. # build cpp-empty-test
  84. if(BUILD_CPP_EMPTY_TEST)
  85. add_subdirectory(tests/cpp-empty-test)
  86. endif(BUILD_CPP_EMPTY_TEST)
  87. # build cpp-tests
  88. if(BUILD_CPP_TESTS)
  89. add_subdirectory(tests/cpp-tests)
  90. endif(BUILD_CPP_TESTS)
  91. ## Scripting
  92. if(BUILD_LUA_LIBS)
  93. add_subdirectory(cocos/scripting/lua-bindings)
  94. # build lua tests
  95. if(BUILD_LUA_TESTS)
  96. add_subdirectory(tests/lua-tests/project)
  97. add_subdirectory(tests/lua-empty-test/project)
  98. endif(BUILD_LUA_TESTS)
  99. endif(BUILD_LUA_LIBS)
  100. ## JS
  101. if(BUILD_JS_LIBS)
  102. add_subdirectory(cocos/scripting/js-bindings)
  103. # build js tests
  104. if(BUILD_JS_TESTS)
  105. add_subdirectory(tests/js-tests/project)
  106. endif(BUILD_JS_TESTS)
  107. endif(BUILD_JS_LIBS)