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
|
|
|
|
#
|
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.
|
|
|
|
# ****************************************************************************/
|
|
|
|
|
2013-11-30 17:11:36 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2014-09-11 07:26:32 +08:00
|
|
|
project (Cocos2d-X)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
|
|
|
# The version number
|
2014-09-16 00:33:07 +08:00
|
|
|
set(COCOS2D_X_VERSION 3.3.0-beta0)
|
2013-11-02 14:40:07 +08:00
|
|
|
|
2014-09-18 10:22:24 +08:00
|
|
|
include(cmake/BuildHelpers.CMakeLists.txt)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
2013-11-02 14:40:07 +08:00
|
|
|
|
2014-08-06 22:43:19 +08:00
|
|
|
message(${BUILDING_STRING})
|
2013-12-02 15:41:27 +08:00
|
|
|
|
2014-08-23 05:28:15 +08:00
|
|
|
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
|
|
|
|
option(USE_BOX2D "Use box2d for physics library" OFF)
|
|
|
|
option(BUILD_STATIC "Build static libraries" ON)
|
|
|
|
option(DEBUG_MODE "Debug or release?" ON)
|
|
|
|
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-09-17 08:34:54 +08:00
|
|
|
option(BUILD_CPP_TESTS "Build TestCpp samples" ON)
|
|
|
|
option(BUILD_LUA_LIBS "Build lua libraries" ON)
|
|
|
|
option(BUILD_LUA_TESTS "Build TestLua samples" ON)
|
2014-08-23 05:28:15 +08:00
|
|
|
|
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})
|
|
|
|
|
2014-09-12 08:36:49 +08:00
|
|
|
# Compiler options
|
2014-08-06 22:43:19 +08:00
|
|
|
if(MSVC)
|
|
|
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
|
|
|
|
-wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710
|
|
|
|
-wd4514 -wd4056 -wd4996 -wd4099)
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
2014-08-06 22:06:37 +08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -std=c99")
|
2014-08-24 18:52:51 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
|
2014-09-12 08:36:49 +08:00
|
|
|
if(CLANG)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
|
|
|
endif()
|
2014-08-06 22:43:19 +08:00
|
|
|
endif(MSVC)
|
2013-11-30 14:09:12 +08:00
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
set (BUILD_TYPE STATIC)
|
|
|
|
else()
|
|
|
|
set (BUILD_TYPE SHARED)
|
|
|
|
endif()
|
|
|
|
|
2014-09-12 08:36:49 +08:00
|
|
|
# Some macro definitions
|
2014-08-06 22:43:19 +08:00
|
|
|
if(WINDOWS)
|
2014-08-23 05:28:15 +08:00
|
|
|
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
ADD_DEFINITIONS (-DCC_STATIC)
|
|
|
|
else()
|
2014-09-17 08:18:24 +08:00
|
|
|
ADD_DEFINITIONS (-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL)
|
2014-08-23 05:28:15 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32)
|
2014-08-06 22:43:19 +08:00
|
|
|
set(PLATFORM_FOLDER win32)
|
|
|
|
elseif(MACOSX)
|
2014-09-10 03:18:31 +08:00
|
|
|
ADD_DEFINITIONS (-DCC_TARGET_OS_MAC)
|
|
|
|
ADD_DEFINITIONS (-DUSE_FILE32API)
|
2014-08-06 22:43:19 +08:00
|
|
|
set(PLATFORM_FOLDER mac)
|
2014-09-10 03:18:31 +08:00
|
|
|
elseif(LINUX)
|
2014-08-06 22:43:19 +08:00
|
|
|
ADD_DEFINITIONS(-DLINUX)
|
|
|
|
set(PLATFORM_FOLDER linux)
|
2014-09-20 08:46:39 +08:00
|
|
|
elseif(ANDROID)
|
|
|
|
ADD_DEFINITIONS (-DUSE_FILE32API)
|
|
|
|
set(PLATFORM_FOLDER android)
|
2014-09-10 03:18:31 +08:00
|
|
|
else()
|
|
|
|
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
|
2013-11-30 14:09:12 +08:00
|
|
|
endif()
|
|
|
|
|
2013-12-02 14:57:47 +08:00
|
|
|
if(MINGW)
|
|
|
|
add_definitions(-DGLEW_STATIC)
|
2014-05-28 00:17:09 +08:00
|
|
|
add_definitions(-D__SSIZE_T)
|
2014-05-30 20:14:22 +08:00
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lws2_32")
|
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32")
|
2013-12-02 14:57:47 +08:00
|
|
|
|
2014-08-06 22:43:19 +08:00
|
|
|
if(CLANG)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions ")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions ")
|
|
|
|
endif()
|
|
|
|
endif()
|
2013-11-30 14:09:12 +08:00
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
# architecture
|
|
|
|
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
2014-09-10 03:18:31 +08:00
|
|
|
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" )
|
|
|
|
endif()
|
|
|
|
|
2014-10-09 12:01:22 +08:00
|
|
|
if(LINUX)
|
|
|
|
set(PLATFORM_INCLUDE_DIR
|
|
|
|
/usr/include/
|
|
|
|
/usr/local/include/GLFW
|
|
|
|
)
|
|
|
|
endif()
|
2014-09-17 08:34:54 +08:00
|
|
|
|
2013-11-02 14:40:07 +08:00
|
|
|
include_directories(
|
2014-09-10 03:18:31 +08:00
|
|
|
${PLATFORM_INCLUDE_DIR}
|
2013-11-30 14:09:12 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cocos
|
2014-08-24 18:52:51 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
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
|
|
|
)
|
|
|
|
|
2014-09-10 03:18:31 +08:00
|
|
|
# Specific Link Directories
|
|
|
|
if(LINUX)
|
|
|
|
set(PLATFORM_LINK_DIR
|
|
|
|
/usr/local/lib
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR}
|
|
|
|
)
|
|
|
|
set(PLATFORM_FOLDER_ARCH
|
|
|
|
${PLATFORM_FOLDER}/${ARCH_DIR}
|
|
|
|
)
|
2014-09-17 08:34:54 +08:00
|
|
|
elseif(NOT MINGW)
|
2014-09-10 03:18:31 +08:00
|
|
|
set(PLATFORM_FOLDER_ARCH
|
|
|
|
${PLATFORM_FOLDER}
|
|
|
|
)
|
|
|
|
set(PLATFORM_LINK_DIR
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2014-09-17 11:23:59 +08:00
|
|
|
|
|
|
|
# NB
|
|
|
|
# we need to return these to libraries to their official state rather than
|
|
|
|
# having our custom cocos2d namespace so that we may use system versions if
|
|
|
|
# the platform provides them. It is very important that this
|
|
|
|
# is done before we make prebuilt versions of these two libs
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../external/unzip
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../external/xxhash
|
|
|
|
|
|
|
|
)
|
|
|
|
|
2014-10-09 12:34:27 +08:00
|
|
|
if(LINUX)
|
|
|
|
|
|
|
|
find_package(GLFW3 REQUIRED)
|
|
|
|
message( STATUS "GLFW3 dirs: ${GLFW3_INCLUDE_DIRS}")
|
|
|
|
include_directories(${GLFW3_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
endif(LINUX)
|
|
|
|
|
2014-09-17 11:23:59 +08:00
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
if(NOT MINGW)
|
2014-09-17 11:23:59 +08:00
|
|
|
|
|
|
|
include_directories(
|
|
|
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/include
|
2014-09-20 09:02:49 +08:00
|
|
|
${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}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/include/${PLATFORM_FOLDER}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER}
|
2014-09-17 11:23:59 +08:00
|
|
|
|
2014-09-20 08:46:39 +08:00
|
|
|
|
2014-09-20 09:02:49 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER}/freetype2
|
2014-09-17 11:23:59 +08:00
|
|
|
)
|
|
|
|
|
2014-09-20 08:46:39 +08:00
|
|
|
#todo: fix location of freetype includes for linux android on cocos prebuilt repo
|
|
|
|
#i.e we should not need to include an extra dir of /freetype2
|
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
link_directories(
|
2014-09-17 11:23:59 +08:00
|
|
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2/prebuilt/${PLATFORM_FOLDER_ARCH}
|
2014-09-17 08:34:54 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/prebuilt/${PLATFORM_FOLDER_ARCH}
|
2014-09-17 11:23:59 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER_ARCH}
|
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
)
|
2014-09-17 11:23:59 +08:00
|
|
|
|
2014-09-18 10:22:24 +08:00
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
endif()
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2014-10-09 12:01:22 +08:00
|
|
|
# build for 3rd party libraries
|
|
|
|
if(LINUX)
|
|
|
|
add_subdirectory(external/Box2D)
|
|
|
|
add_subdirectory(external/unzip)
|
|
|
|
add_subdirectory(external/xxhash)
|
|
|
|
add_subdirectory(external/tinyxml2)
|
|
|
|
endif()
|
2014-09-17 11:23:59 +08:00
|
|
|
|
2014-08-24 18:52:51 +08:00
|
|
|
# libcocos2d.a
|
2014-05-02 04:01:51 +08:00
|
|
|
add_subdirectory(cocos)
|
2013-11-02 18:07:34 +08:00
|
|
|
|
2014-09-17 08:34:54 +08:00
|
|
|
# build cpp tests
|
|
|
|
if(BUILD_CPP_TESTS)
|
|
|
|
add_subdirectory(tests/cpp-empty-test)
|
|
|
|
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-17 08:34:54 +08:00
|
|
|
endif(BUILD_LUA_LIBS)
|