2013-12-05 11:37:27 +08:00
|
|
|
#/****************************************************************************
|
|
|
|
# Copyright (c) 2013 cocos2d-x.org
|
|
|
|
# Copyright (c) 2012-2013 martell malone
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
# ****************************************************************************/
|
|
|
|
|
2013-11-30 17:11:36 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2013-11-06 19:15:20 +08:00
|
|
|
project (Cocos2dx)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
|
|
|
# The version number
|
|
|
|
set(Cocos2dxSamples_VERSION_MAJOR 3)
|
|
|
|
set(Cocos2dxSamples_VERSION_MINOR 0)
|
|
|
|
|
2013-11-02 16:31:52 +08:00
|
|
|
include(build/BuildHelpers.CMakeLists.txt)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
2013-12-02 15:41:27 +08:00
|
|
|
if(WIN32 OR APPLE)
|
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
|
|
|
|
option(USE_BOX2D "Use box2d for physics library" OFF)
|
|
|
|
option(DEBUG_MODE "Debug or release?" ON)
|
2014-03-10 17:10:08 +08:00
|
|
|
option(BUILD_LIBS_LUA "Build lua libraries" OFF)
|
2014-01-08 16:58:36 +08:00
|
|
|
option(BUILD_GUI "Build GUI library" ON)
|
|
|
|
option(BUILD_NETWORK "Build network library" ON)
|
2014-02-11 22:10:42 +08:00
|
|
|
option(BUILD_STORAGE "Build storage library" ON)
|
2014-01-08 16:58:36 +08:00
|
|
|
option(BUILD_EXTENSIONS "Build extension library" ON)
|
|
|
|
option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
|
|
|
|
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
|
|
|
|
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
|
2013-11-06 19:15:20 +08:00
|
|
|
|
2014-03-11 17:52:28 +08:00
|
|
|
option(BUILD_CppTests "Only build TestCpp sample" ON)
|
|
|
|
option(BUILD_LuaTests "Only build TestLua sample" OFF)
|
2013-12-02 15:41:27 +08:00
|
|
|
else()#temp
|
|
|
|
|
|
|
|
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
|
|
|
|
option(USE_BOX2D "Use box2d for physics library" OFF)
|
|
|
|
option(DEBUG_MODE "Debug or release?" ON)
|
2014-03-10 17:10:08 +08:00
|
|
|
option(BUILD_LIBS_LUA "Build lua libraries" ON)
|
2013-12-02 15:41:27 +08:00
|
|
|
option(BUILD_GUI "Build GUI library" ON)
|
|
|
|
option(BUILD_NETWORK "Build network library" ON)
|
2014-02-11 22:10:42 +08:00
|
|
|
option(BUILD_STORAGE "Build storage library" ON)
|
2013-12-02 15:41:27 +08:00
|
|
|
option(BUILD_EXTENSIONS "Build extension library" ON)
|
|
|
|
option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
|
|
|
|
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
|
|
|
|
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
|
|
|
|
|
2014-03-11 17:52:28 +08:00
|
|
|
option(BUILD_CppTests "Only build TestCpp sample" ON)
|
|
|
|
option(BUILD_LuaTests "Only build TestLua sample" ON)
|
2013-12-02 15:41:27 +08:00
|
|
|
endif()#temp
|
|
|
|
|
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
if(DEBUG_MODE)
|
2013-11-07 05:24:33 +08:00
|
|
|
set(CMAKE_BUILD_TYPE DEBUG)
|
2013-11-06 19:15:20 +08:00
|
|
|
else(DEBUG_MODE)
|
2013-11-07 05:24:33 +08:00
|
|
|
set(CMAKE_BUILD_TYPE RELEASE)
|
2013-11-06 19:15:20 +08:00
|
|
|
endif(DEBUG_MODE)
|
|
|
|
|
2013-11-30 14:09:12 +08:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
|
|
|
2013-11-30 16:08:58 +08:00
|
|
|
if(WIN32)
|
2013-12-02 14:57:47 +08:00
|
|
|
ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32)
|
2013-11-30 14:09:12 +08:00
|
|
|
|
2013-11-30 16:08:58 +08:00
|
|
|
if(MSVC)
|
|
|
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS
|
|
|
|
-D_SCL_SECURE_NO_WARNINGS
|
|
|
|
-wd4251 -wd4244 -wd4334
|
|
|
|
-wd4005 -wd4820 -wd4710
|
2013-11-30 16:27:34 +08:00
|
|
|
-wd4514 -wd4056 -wd4996 -wd4099)
|
2013-11-30 16:08:58 +08:00
|
|
|
else(MSVC)#MINGW
|
|
|
|
|
|
|
|
endif(MSVC)
|
|
|
|
elseif(APPLE)
|
2013-11-02 16:31:52 +08:00
|
|
|
|
|
|
|
|
2013-11-30 16:08:58 +08:00
|
|
|
else()#Linux
|
|
|
|
ADD_DEFINITIONS(-DLINUX)
|
|
|
|
endif()
|
2013-11-30 14:09:12 +08:00
|
|
|
|
|
|
|
|
2013-11-30 16:08:58 +08:00
|
|
|
if(NOT MSVC)# all gcc
|
2013-12-02 14:57:47 +08:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
2013-11-30 16:08:58 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
|
|
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99")
|
|
|
|
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
|
2013-11-30 14:09:12 +08:00
|
|
|
endif()
|
|
|
|
|
2013-12-02 14:57:47 +08:00
|
|
|
if(MINGW)
|
|
|
|
add_definitions(-DGLEW_STATIC)
|
|
|
|
endif()
|
|
|
|
|
2013-11-30 14:09:12 +08:00
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
if(USE_CHIPMUNK)
|
|
|
|
message("Using chipmunk ...")
|
2013-11-30 14:09:12 +08:00
|
|
|
add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
|
2013-11-06 19:15:20 +08:00
|
|
|
elseif(USE_BOX2D)
|
|
|
|
message("Using box2d ...")
|
2013-11-30 14:09:12 +08:00
|
|
|
add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1)
|
2013-11-06 19:15:20 +08:00
|
|
|
else(USE_CHIPMUNK)
|
|
|
|
message(FATAL_ERROR "Must choose a physics library.")
|
|
|
|
endif(USE_CHIPMUNK)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
|
|
|
# architecture
|
|
|
|
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
|
|
|
set(ARCH_DIR "64-bit")
|
|
|
|
else()
|
|
|
|
set(ARCH_DIR "32-bit")
|
|
|
|
endif()
|
|
|
|
|
2013-11-30 14:09:12 +08:00
|
|
|
if(WIN32) # Win32
|
|
|
|
set(PLATFORM_FOLDER win32)
|
|
|
|
elseif(APPLE)# osx or ios
|
|
|
|
set(PLATFORM_FOLDER mac)
|
|
|
|
else() # Assume Linux
|
|
|
|
set(PLATFORM_FOLDER linux)
|
|
|
|
endif()
|
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
include_directories(
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/audio/include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d
|
2013-12-17 14:50:40 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/renderer
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/base
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/physics
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/editor-support
|
2014-03-05 09:24:04 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/math/kazmath
|
2014-03-11 18:18:19 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/scripting/lua-bindings/auto
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/scripting/lua-bindings/manual
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/extensions
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/unzip
|
2013-12-13 12:42:15 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/edtaa3func
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk
|
2014-01-23 05:05:37 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/desktop
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/include/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/include/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER}
|
2014-02-11 22:21:15 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/include/${PLATFORM_FOLDER}
|
2013-11-02 14:40:07 +08:00
|
|
|
)
|
|
|
|
|
2013-11-30 14:09:12 +08:00
|
|
|
if(WIN32)
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include
|
2014-01-23 17:05:48 +08:00
|
|
|
external/curl/include/${PLATFORM_FOLDER}
|
2013-11-30 14:09:12 +08:00
|
|
|
)
|
|
|
|
elseif(APPLE)
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER}
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
include_directories(
|
2014-01-23 17:05:48 +08:00
|
|
|
/usr/include
|
2014-02-11 23:35:52 +08:00
|
|
|
/usr/include/GLFW
|
2014-01-23 17:05:48 +08:00
|
|
|
/usr/local/include/GLFW
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if(WIN32)
|
2013-12-02 14:57:47 +08:00
|
|
|
|
|
|
|
if(NOT MINGW)
|
2013-11-30 14:09:12 +08:00
|
|
|
link_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}
|
2014-01-23 17:05:48 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt
|
2013-11-30 14:09:12 +08:00
|
|
|
)
|
2013-12-02 14:57:47 +08:00
|
|
|
endif()
|
|
|
|
|
2013-11-30 14:09:12 +08:00
|
|
|
elseif(APPLE)
|
|
|
|
|
|
|
|
else()
|
|
|
|
|
|
|
|
link_directories(
|
|
|
|
/usr/local/lib
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
2014-02-11 22:21:15 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
endif()
|
2013-11-02 14:40:07 +08:00
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
# kazmath
|
|
|
|
add_subdirectory(cocos/math/kazmath)
|
|
|
|
|
|
|
|
# chipmunk library
|
|
|
|
add_subdirectory(external/chipmunk/src)
|
|
|
|
|
2013-11-02 18:07:34 +08:00
|
|
|
# box2d library
|
|
|
|
add_subdirectory(external/Box2D)
|
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
# unzip library
|
|
|
|
add_subdirectory(external/unzip)
|
|
|
|
|
|
|
|
# tinyxml2 library
|
|
|
|
add_subdirectory(external/tinyxml2)
|
|
|
|
|
2013-11-02 18:07:34 +08:00
|
|
|
# audio
|
|
|
|
add_subdirectory(cocos/audio)
|
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
# cocos base library
|
|
|
|
add_subdirectory(cocos/base)
|
|
|
|
|
|
|
|
# cocos 2d library
|
|
|
|
add_subdirectory(cocos/2d)
|
|
|
|
|
2014-02-11 22:10:42 +08:00
|
|
|
if(BUILD_STORAGE)
|
|
|
|
# cocos storage
|
|
|
|
add_subdirectory(cocos/storage)
|
|
|
|
endif(BUILD_STORAGE)
|
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
if(BUILD_GUI)
|
|
|
|
# gui
|
2013-11-02 18:07:34 +08:00
|
|
|
add_subdirectory(cocos/gui)
|
2013-11-06 19:15:20 +08:00
|
|
|
endif(BUILD_GUI)
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
if(BUILD_NETWORK)
|
|
|
|
# network
|
2013-11-02 18:07:34 +08:00
|
|
|
add_subdirectory(cocos/network)
|
2013-11-06 19:15:20 +08:00
|
|
|
endif(BUILD_NETWORK)
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
if(BUILD_EXTENSIONS)
|
|
|
|
# extensions
|
2013-11-04 13:10:04 +08:00
|
|
|
add_subdirectory(extensions)
|
2013-11-06 19:15:20 +08:00
|
|
|
endif(BUILD_EXTENSIONS)
|
2013-11-04 13:10:04 +08:00
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
## Editor Support
|
|
|
|
|
|
|
|
if(BUILD_EDITOR_SPINE)
|
|
|
|
# spine
|
2013-11-02 18:07:34 +08:00
|
|
|
add_subdirectory(cocos/editor-support/spine)
|
2013-11-06 19:15:20 +08:00
|
|
|
endif(BUILD_EDITOR_SPINE)
|
|
|
|
|
|
|
|
if(BUILD_EDITOR_COCOSBUILDER)
|
|
|
|
# cocosbuilder
|
2013-11-02 18:07:34 +08:00
|
|
|
add_subdirectory(cocos/editor-support/cocosbuilder)
|
2013-11-06 19:15:20 +08:00
|
|
|
endif(BUILD_EDITOR_COCOSBUILDER)
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2013-11-06 19:15:20 +08:00
|
|
|
if(BUILD_EDITOR_COCOSTUDIO)
|
|
|
|
# cocostudio
|
|
|
|
add_subdirectory(cocos/editor-support/cocostudio)
|
|
|
|
endif(BUILD_EDITOR_COCOSTUDIO)
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2014-03-10 17:10:08 +08:00
|
|
|
## Scripting
|
|
|
|
if(BUILD_LIBS_LUA)
|
|
|
|
# lua
|
|
|
|
add_subdirectory(external/lua/lua)
|
|
|
|
|
|
|
|
# tolua
|
|
|
|
add_subdirectory(external/lua/tolua)
|
|
|
|
|
|
|
|
# luabinding
|
2014-03-10 17:39:54 +08:00
|
|
|
add_subdirectory(cocos/scripting/lua-bindings)
|
2014-03-10 17:10:08 +08:00
|
|
|
endif(BUILD_LIBS_LUA)
|
|
|
|
|
2014-02-01 06:09:28 +08:00
|
|
|
# build tests
|
2013-12-31 15:08:21 +08:00
|
|
|
|
2014-03-11 17:52:28 +08:00
|
|
|
add_subdirectory(tests/cpp-empty-test)
|
2013-12-31 15:08:21 +08:00
|
|
|
|
2014-03-11 17:52:28 +08:00
|
|
|
if(BUILD_CppTests)
|
|
|
|
add_subdirectory(tests/cpp-tests)
|
|
|
|
endif(BUILD_CppTests)
|
|
|
|
|
2014-03-11 17:52:56 +08:00
|
|
|
add_subdirectory(tests/lua-empty-test/project)
|
2014-03-11 17:52:28 +08:00
|
|
|
|
|
|
|
if(BUILD_LuaTests)
|
|
|
|
add_subdirectory(tests/lua-tests/project)
|
|
|
|
endif(BUILD_LuaTests)
|