2013-12-05 11:37:27 +08:00
|
|
|
#/****************************************************************************
|
|
|
|
# Copyright (c) 2013 cocos2d-x.org
|
2014-08-06 22:43:19 +08:00
|
|
|
# Copyright (c) 2014 martell malone
|
2016-03-03 08:51:54 +08:00
|
|
|
# Copyright (c) 2015 Chukong Technologies Inc.
|
2014-08-06 22:43:19 +08:00
|
|
|
#
|
2013-12-05 11:37:27 +08:00
|
|
|
# http://www.cocos2d-x.org
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
# ****************************************************************************/
|
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2014-11-25 19:19:49 +08:00
|
|
|
# It ensures that when Find*.cmake files included from cmake's Modules dir
|
|
|
|
# include another *.cmake file with relative path, that file will be included
|
|
|
|
# also from cmake's Modules dir, to not clash with per-project files.
|
|
|
|
cmake_policy(SET CMP0017 NEW)
|
|
|
|
|
2015-04-06 14:21:41 +08:00
|
|
|
# Use new behaviour with cmake >= 3.1:
|
2015-01-26 15:15:41 +08:00
|
|
|
# Only interpret if() arguments as variables or keywords when unquoted.
|
2015-04-06 14:21:41 +08:00
|
|
|
if(CMAKE_VERSION VERSION_GREATER 3.1)
|
2015-01-26 15:15:41 +08:00
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
endif()
|
|
|
|
|
2014-09-11 07:26:32 +08:00
|
|
|
project (Cocos2d-X)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
|
|
|
# The version number
|
2016-03-03 08:51:54 +08:00
|
|
|
set(COCOS2D_X_VERSION 3.11)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
# define some variables
|
2014-08-23 05:28:15 +08:00
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
|
|
|
|
set(COCOS_EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
|
|
|
# architecture
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(ARCH_DIR "64-bit")
|
|
|
|
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
|
|
set(ARCH_DIR "32-bit")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported architecture, CMake will exit")
|
|
|
|
return()
|
2014-11-19 08:28:41 +08:00
|
|
|
endif()
|
2016-03-05 04:49:40 +08:00
|
|
|
# CMAKE_BUILD_TYPE has precedence over DEBUG_MODE
|
|
|
|
# Still supporting DEBUG_MODE for backwards compatibility
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
if(DEBUG_MODE)
|
|
|
|
set(CMAKE_BUILD_TYPE DEBUG)
|
|
|
|
else(DEBUG_MODE)
|
|
|
|
set(CMAKE_BUILD_TYPE RELEASE)
|
|
|
|
endif(DEBUG_MODE)
|
|
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
2013-11-06 19:15:20 +08:00
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
include(CocosBuildHelpers)
|
2014-08-23 05:28:15 +08:00
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
message(${BUILDING_STRING})
|
2013-11-30 14:09:12 +08:00
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
# SelectModule() is a macro to select building modules
|
|
|
|
include(SelectModule)
|
|
|
|
SelectModule()
|
2013-12-02 14:57:47 +08:00
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
# set compiler options
|
|
|
|
include(SetCompilerOptions)
|
|
|
|
SetCompilerOptions()
|
2014-09-10 03:18:31 +08:00
|
|
|
|
2015-10-23 07:12:37 +08:00
|
|
|
if (CMAKE_FIND_ROOT_PATH AND USE_PREBUILT_LIBS)
|
|
|
|
# Adds cocos2d-x external folder to the list of valid include/library paths when cross-compiling and using prebuilds
|
|
|
|
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR})
|
|
|
|
endif ()
|
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
include_directories(
|
2014-08-24 18:52:51 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2016-04-18 15:03:06 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos
|
2014-10-09 12:01:22 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/deprecated
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/platform
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/extensions
|
2014-08-25 10:12:36 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external
|
2013-11-02 14:40:07 +08:00
|
|
|
)
|
2015-10-23 07:12:37 +08:00
|
|
|
|
2014-11-20 17:05:15 +08:00
|
|
|
if(USE_PREBUILT_LIBS)
|
|
|
|
include(CocosUsePrebuiltLibs)
|
|
|
|
endif()
|
|
|
|
|
2016-04-18 15:03:06 +08:00
|
|
|
include(BuildModules)
|
|
|
|
BuildModules()
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
# build cpp-empty-test
|
|
|
|
if(BUILD_CPP_EMPTY_TEST)
|
2014-09-17 08:34:54 +08:00
|
|
|
add_subdirectory(tests/cpp-empty-test)
|
2016-03-03 08:51:54 +08:00
|
|
|
endif(BUILD_CPP_EMPTY_TEST)
|
|
|
|
|
|
|
|
# build cpp-tests
|
|
|
|
if(BUILD_CPP_TESTS)
|
2014-09-17 08:34:54 +08:00
|
|
|
add_subdirectory(tests/cpp-tests)
|
|
|
|
endif(BUILD_CPP_TESTS)
|
|
|
|
|
2014-03-10 17:10:08 +08:00
|
|
|
## Scripting
|
2014-09-17 08:34:54 +08:00
|
|
|
if(BUILD_LUA_LIBS)
|
|
|
|
add_subdirectory(cocos/scripting/lua-bindings)
|
2014-06-04 11:50:04 +08:00
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
# build lua tests
|
|
|
|
if(BUILD_LUA_TESTS)
|
|
|
|
add_subdirectory(tests/lua-tests/project)
|
|
|
|
add_subdirectory(tests/lua-empty-test/project)
|
|
|
|
endif(BUILD_LUA_TESTS)
|
2014-03-11 17:52:28 +08:00
|
|
|
|
2014-09-27 16:26:35 +08:00
|
|
|
endif(BUILD_LUA_LIBS)
|
2015-04-15 14:02:04 +08:00
|
|
|
|
|
|
|
## JS
|
|
|
|
if(BUILD_JS_LIBS)
|
2015-04-23 16:51:57 +08:00
|
|
|
add_subdirectory(cocos/scripting/js-bindings)
|
2015-04-15 14:02:04 +08:00
|
|
|
|
2015-04-23 10:42:44 +08:00
|
|
|
# build js tests
|
2015-04-15 14:02:04 +08:00
|
|
|
if(BUILD_JS_TESTS)
|
2015-04-23 10:42:44 +08:00
|
|
|
add_subdirectory(tests/js-tests/project)
|
2015-04-15 14:02:04 +08:00
|
|
|
endif(BUILD_JS_TESTS)
|
|
|
|
|
|
|
|
endif(BUILD_JS_LIBS)
|