2013-11-08 18:13:24 +08:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
|
2014-01-07 11:34:48 +08:00
|
|
|
set(APP_NAME MyGame)
|
2013-11-08 18:13:24 +08:00
|
|
|
project (${APP_NAME})
|
|
|
|
|
2013-12-25 18:32:23 +08:00
|
|
|
include(cocos2d/build/BuildHelpers.CMakeLists.txt)
|
2013-11-08 18:13:24 +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)
|
|
|
|
|
|
|
|
if(DEBUG_MODE)
|
|
|
|
set(CMAKE_BUILD_TYPE DEBUG)
|
|
|
|
else(DEBUG_MODE)
|
|
|
|
set(CMAKE_BUILD_TYPE RELEASE)
|
|
|
|
endif(DEBUG_MODE)
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
|
|
|
2014-02-17 21:23:29 +08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
2013-11-08 18:13:24 +08:00
|
|
|
|
|
|
|
if(USE_CHIPMUNK)
|
|
|
|
message("Using chipmunk ...")
|
|
|
|
add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
|
|
|
|
elseif(USE_BOX2D)
|
|
|
|
message("Using box2d ...")
|
|
|
|
add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1)
|
|
|
|
else(USE_CHIPMUNK)
|
|
|
|
message(FATAL_ERROR "Must choose a physics library.")
|
|
|
|
endif(USE_CHIPMUNK)
|
|
|
|
|
|
|
|
# architecture
|
|
|
|
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
|
|
|
set(ARCH_DIR "64-bit")
|
|
|
|
else()
|
|
|
|
set(ARCH_DIR "32-bit")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
set(GAME_SRC
|
|
|
|
proj.linux/main.cpp
|
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
|
|
|
)
|
|
|
|
|
2013-12-26 10:22:39 +08:00
|
|
|
set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)
|
2013-11-08 18:13:24 +08:00
|
|
|
|
|
|
|
include_directories(
|
2014-01-23 17:05:48 +08:00
|
|
|
/usr/local/include/GLFW
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}
|
|
|
|
${COCOS2D_ROOT}/cocos
|
|
|
|
${COCOS2D_ROOT}/cocos/audio/include
|
|
|
|
${COCOS2D_ROOT}/cocos/2d
|
2013-12-25 11:01:23 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/2d/renderer
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/2d/platform
|
2014-01-23 11:07:54 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/2d/platform/desktop
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/2d/platform/linux
|
|
|
|
${COCOS2D_ROOT}/cocos/base
|
|
|
|
${COCOS2D_ROOT}/cocos/physics
|
|
|
|
${COCOS2D_ROOT}/cocos/editor-support
|
2014-03-05 09:27:37 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/math/kazmath
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/extensions
|
|
|
|
${COCOS2D_ROOT}/external
|
2013-12-25 11:01:23 +08:00
|
|
|
${COCOS2D_ROOT}/external/edtaa3func
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/external/jpeg/include/linux
|
|
|
|
${COCOS2D_ROOT}/external/tiff/include/linux
|
|
|
|
${COCOS2D_ROOT}/external/webp/include/linux
|
|
|
|
${COCOS2D_ROOT}/external/tinyxml2
|
|
|
|
${COCOS2D_ROOT}/external/unzip
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/include/linux
|
2014-02-11 22:21:15 +08:00
|
|
|
${COCOS2D_ROOT}/external/websockets/include/linux
|
2014-02-11 22:25:59 +08:00
|
|
|
${COCOS2D_ROOT}/external/spidermonkey/include/linux
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
link_directories(
|
|
|
|
/usr/local/lib
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR}
|
|
|
|
${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR}
|
|
|
|
${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR}
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR}
|
2014-02-11 22:21:15 +08:00
|
|
|
${COCOS2D_ROOT}/external/websockets/prebuilt/linux/${ARCH_DIR}
|
2014-02-11 22:25:59 +08:00
|
|
|
${COCOS2D_ROOT}/external/spidermonkey/prebuilt/linux/${ARCH_DIR}
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
|
|
|
|
)
|
|
|
|
|
2014-01-07 11:34:48 +08:00
|
|
|
# kazmath
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath)
|
|
|
|
|
|
|
|
# chipmunk library
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src)
|
|
|
|
|
|
|
|
# box2d library
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/Box2D)
|
|
|
|
|
|
|
|
# unzip library
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/unzip)
|
|
|
|
|
|
|
|
# tinyxml2 library
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2)
|
|
|
|
|
|
|
|
# audio
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/audio)
|
|
|
|
|
|
|
|
# cocos base library
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/base)
|
|
|
|
|
|
|
|
# cocos 2d library
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/2d)
|
|
|
|
|
2014-02-11 22:10:42 +08:00
|
|
|
# cocos storage
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/storage)
|
|
|
|
|
2014-03-11 20:46:11 +08:00
|
|
|
# ui
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/ui)
|
2014-01-07 11:34:48 +08:00
|
|
|
|
|
|
|
# network
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/network)
|
|
|
|
|
|
|
|
# extensions
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/extensions)
|
|
|
|
|
|
|
|
## Editor Support
|
|
|
|
|
|
|
|
# spine
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine)
|
|
|
|
|
|
|
|
# cocosbuilder
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder)
|
|
|
|
|
|
|
|
# cocostudio
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio)
|
|
|
|
|
2013-11-08 18:13:24 +08:00
|
|
|
# add the executable
|
|
|
|
add_executable(${APP_NAME}
|
|
|
|
${GAME_SRC}
|
|
|
|
)
|
|
|
|
|
|
|
|
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
|
|
|
set(FMOD_LIB "fmodex64")
|
|
|
|
else()
|
|
|
|
set(FMOD_LIB "fmodex")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(${APP_NAME}
|
2014-03-11 20:46:11 +08:00
|
|
|
ui
|
2013-11-08 18:13:24 +08:00
|
|
|
network
|
2014-02-11 22:10:42 +08:00
|
|
|
storage
|
2013-11-08 18:13:24 +08:00
|
|
|
spine
|
|
|
|
cocostudio
|
|
|
|
cocosbuilder
|
|
|
|
extensions
|
|
|
|
audio
|
|
|
|
cocos2d
|
|
|
|
)
|
|
|
|
|
2014-01-07 15:55:57 +08:00
|
|
|
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
|
2013-11-08 18:13:24 +08:00
|
|
|
|
|
|
|
set_target_properties(${APP_NAME} PROPERTIES
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
|
|
|
|
|
|
|
pre_build(${APP_NAME}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
|
|
|
|
)
|
|
|
|
|