2014-08-24 18:52:51 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-01-07 11:34:48 +08:00
|
|
|
set(APP_NAME MyGame)
|
2013-11-08 18:13:24 +08:00
|
|
|
project (${APP_NAME})
|
|
|
|
|
2014-10-13 16:52:14 +08:00
|
|
|
include(cocos2d/cmake/BuildHelpers.CMakeLists.txt)
|
2013-11-08 18:13:24 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2014-05-04 14:02:00 +08:00
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-05-04 14:02:00 +08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
|
|
|
|
2014-10-15 21:33:58 +08:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -std=c99")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11 -stdlib=libc++ -Wno-deprecated-declarations -Wno-reorder")
|
|
|
|
|
2014-05-04 14:02:00 +08:00
|
|
|
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
2014-08-24 18:52:51 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
|
2014-05-04 14:02:00 +08:00
|
|
|
endif()
|
2013-11-08 18:13:24 +08:00
|
|
|
|
|
|
|
# architecture
|
|
|
|
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
|
|
|
set(ARCH_DIR "64-bit")
|
|
|
|
else()
|
|
|
|
set(ARCH_DIR "32-bit")
|
|
|
|
endif()
|
|
|
|
|
2014-10-15 21:33:58 +08:00
|
|
|
if( APPLE AND IOS )
|
|
|
|
include_directories(Classes)
|
|
|
|
set(GAME_SRC
|
|
|
|
proj.ios_mac/ios/main.m
|
|
|
|
proj.ios_mac/ios/RootViewController.mm
|
|
|
|
proj.ios_mac/ios/AppController.mm
|
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
|
|
|
)
|
|
|
|
set(GAME_HEADERS
|
|
|
|
Classes/AppDelegate.h
|
|
|
|
Classes/HelloWorldScene.h
|
|
|
|
proj.ios_mac/ios/RootViewController.h
|
|
|
|
proj.ios_mac/ios/AppController.h
|
|
|
|
)
|
|
|
|
elseif(APPLE) #desktop
|
|
|
|
include_directories(Classes)
|
|
|
|
include(Classes/CMakeLists.txt)
|
|
|
|
set(GAME_SRC
|
|
|
|
proj.ios_mac/mac/main.cpp
|
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
|
|
|
)
|
|
|
|
set(GAME_HEADERS
|
|
|
|
Classes/AppDelegate.h
|
|
|
|
Classes/HelloWorldScene.h
|
|
|
|
)
|
|
|
|
elseif( UNIX AND NOT APPLE) #assume linux
|
2013-11-08 18:13:24 +08:00
|
|
|
set(GAME_SRC
|
|
|
|
proj.linux/main.cpp
|
2014-09-13 17:50:02 +08:00
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
2013-11-08 18:13:24 +08:00
|
|
|
)
|
2014-05-04 14:02:00 +08:00
|
|
|
elseif ( WIN32 )
|
|
|
|
set(GAME_SRC
|
|
|
|
proj.win32/main.cpp
|
|
|
|
proj.win32/main.h
|
|
|
|
proj.win32/resource.h
|
2014-09-13 17:50:02 +08:00
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
2014-05-04 14:02:00 +08:00
|
|
|
)
|
|
|
|
endif()
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2013-12-26 10:22:39 +08:00
|
|
|
set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)
|
2014-05-04 14:02:00 +08:00
|
|
|
if (WIN32)
|
|
|
|
include_directories(
|
|
|
|
${COCOS2D_ROOT}
|
|
|
|
${COCOS2D_ROOT}/cocos
|
|
|
|
${COCOS2D_ROOT}/cocos/audio/include
|
|
|
|
${COCOS2D_ROOT}/cocos/2d
|
|
|
|
${COCOS2D_ROOT}/cocos/2d/renderer
|
|
|
|
${COCOS2D_ROOT}/cocos/2d/platform
|
|
|
|
${COCOS2D_ROOT}/cocos/2d/platform/desktop
|
|
|
|
${COCOS2D_ROOT}/cocos/2d/platform/win32
|
|
|
|
${COCOS2D_ROOT}/cocos/base
|
|
|
|
${COCOS2D_ROOT}/cocos/deprecated
|
|
|
|
${COCOS2D_ROOT}/cocos/physics
|
|
|
|
${COCOS2D_ROOT}/cocos/editor-support
|
|
|
|
${COCOS2D_ROOT}/cocos/math
|
|
|
|
${COCOS2D_ROOT}/extensions
|
|
|
|
${COCOS2D_ROOT}/external
|
|
|
|
${COCOS2D_ROOT}/external/edtaa3func
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/png/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/tiff/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/webp/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/curl/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/tinyxml2
|
|
|
|
${COCOS2D_ROOT}/external/unzip
|
|
|
|
${COCOS2D_ROOT}/external/sqlite3/include
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/websockets/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/spidermonkey/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/glfw3/include/win32
|
|
|
|
${COCOS2D_ROOT}/external/win32-specific/gles/include/OGLES
|
|
|
|
${COCOS2D_ROOT}/external/win32-specific/icon/include
|
|
|
|
${COCOS2D_ROOT}/external/win32-specific/zlib/include
|
|
|
|
${COCOS2D_ROOT}/external/xxhash
|
|
|
|
)
|
|
|
|
link_directories(
|
|
|
|
/usr/local/lib
|
|
|
|
${COCOS2D_ROOT}/external/png/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/tiff/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/glfw3/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/webp/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/curl/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/sqlite3/libraries/win32
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/websockets/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/spidermonkey/prebuilt/win32
|
|
|
|
${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt
|
|
|
|
${COCOS2D_ROOT}/external/win32-specific/icon/prebuilt
|
|
|
|
${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt
|
|
|
|
)
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-05-04 14:02:00 +08:00
|
|
|
elseif(UNIX) #assumed linux
|
2013-11-08 18:13:24 +08:00
|
|
|
include_directories(
|
2014-01-23 17:05:48 +08:00
|
|
|
/usr/local/include/GLFW
|
2014-07-02 10:11:51 +08:00
|
|
|
/usr/include/GLFW
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}
|
|
|
|
${COCOS2D_ROOT}/cocos
|
|
|
|
${COCOS2D_ROOT}/cocos/audio/include
|
2014-05-19 09:34:53 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/platform
|
|
|
|
${COCOS2D_ROOT}/cocos/platform/desktop
|
|
|
|
${COCOS2D_ROOT}/cocos/platform/linux
|
2013-11-08 18:13:24 +08:00
|
|
|
${COCOS2D_ROOT}/cocos/editor-support
|
|
|
|
${COCOS2D_ROOT}/extensions
|
|
|
|
${COCOS2D_ROOT}/external
|
2013-12-25 11:01:23 +08:00
|
|
|
${COCOS2D_ROOT}/external/edtaa3func
|
2014-10-13 16:52:14 +08:00
|
|
|
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
|
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/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}
|
2014-04-01 16:49:24 +08:00
|
|
|
${COCOS2D_ROOT}/external/xxhash
|
2013-11-08 18:13:24 +08:00
|
|
|
)
|
2014-10-15 21:33:58 +08:00
|
|
|
elseif(APPLE AND IOS)
|
|
|
|
include_directories(
|
|
|
|
/usr/local/include/GLFW
|
|
|
|
/usr/include/GLFW
|
|
|
|
${COCOS2D_ROOT}
|
|
|
|
${COCOS2D_ROOT}/cocos
|
|
|
|
${COCOS2D_ROOT}/cocos/audio/include
|
|
|
|
${COCOS2D_ROOT}/cocos/platform
|
|
|
|
${COCOS2D_ROOT}/cocos/platform/ios
|
|
|
|
${COCOS2D_ROOT}/cocos/editor-support
|
|
|
|
${COCOS2D_ROOT}/extensions
|
|
|
|
${COCOS2D_ROOT}/external
|
|
|
|
${COCOS2D_ROOT}/external/edtaa3func
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/include/ios
|
|
|
|
${COCOS2D_ROOT}/external/tiff/include/ios
|
|
|
|
${COCOS2D_ROOT}/external/webp/include/ios
|
|
|
|
${COCOS2D_ROOT}/external/tinyxml2
|
|
|
|
${COCOS2D_ROOT}/external/unzip
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/include/ios
|
|
|
|
${COCOS2D_ROOT}/external/websockets/include/ios
|
|
|
|
${COCOS2D_ROOT}/external/spidermonkey/include/liniosux
|
|
|
|
${COCOS2D_ROOT}/external/xxhash
|
|
|
|
)
|
|
|
|
elseif(APPLE) #assumed linux
|
|
|
|
include_directories(
|
|
|
|
/usr/local/include/GLFW
|
|
|
|
/usr/include/GLFW
|
|
|
|
${COCOS2D_ROOT}
|
|
|
|
${COCOS2D_ROOT}/cocos
|
|
|
|
${COCOS2D_ROOT}/cocos/audio/include
|
|
|
|
${COCOS2D_ROOT}/cocos/platform
|
|
|
|
${COCOS2D_ROOT}/cocos/platform/mac
|
|
|
|
${COCOS2D_ROOT}/cocos/editor-support
|
|
|
|
${COCOS2D_ROOT}/extensions
|
|
|
|
${COCOS2D_ROOT}/external
|
|
|
|
${COCOS2D_ROOT}/external/edtaa3func
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/include/mac
|
|
|
|
${COCOS2D_ROOT}/external/tiff/include/mac
|
|
|
|
${COCOS2D_ROOT}/external/webp/include/mac
|
|
|
|
${COCOS2D_ROOT}/external/tinyxml2
|
|
|
|
${COCOS2D_ROOT}/external/unzip
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/include/mac
|
|
|
|
${COCOS2D_ROOT}/external/websockets/include/mac
|
|
|
|
${COCOS2D_ROOT}/external/spidermonkey/include/liniosux
|
|
|
|
${COCOS2D_ROOT}/external/xxhash
|
|
|
|
)
|
|
|
|
endif()
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-10-15 21:33:58 +08:00
|
|
|
if(NOT APPLE)
|
2014-08-24 18:52:51 +08:00
|
|
|
ADD_DEFINITIONS(-DLINUX)
|
2014-10-15 21:33:58 +08:00
|
|
|
endif()
|
2014-08-24 18:52:51 +08:00
|
|
|
|
2014-10-15 21:33:58 +08:00
|
|
|
if(LINUX)
|
2013-11-08 18:13:24 +08:00
|
|
|
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-09-21 23:49:43 +08:00
|
|
|
${COCOS2D_ROOT}/external/chipmunk/prebuilt/linux/${ARCH_DIR}
|
2013-11-08 18:13:24 +08:00
|
|
|
)
|
2014-10-15 21:33:58 +08:00
|
|
|
elseif(APPLE AND IOS)
|
|
|
|
link_directories(
|
|
|
|
/usr/local/lib
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/tiff/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/webp/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/websockets/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/prebuilt/ios
|
|
|
|
)
|
|
|
|
elseif(APPLE)
|
|
|
|
if(IOS)
|
|
|
|
link_directories(
|
|
|
|
/usr/local/lib
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/tiff/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/webp/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/websockets/prebuilt/ios
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/prebuilt/ios
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
link_directories(
|
|
|
|
/usr/local/lib
|
|
|
|
${COCOS2D_ROOT}/external/jpeg/prebuilt/mac
|
|
|
|
${COCOS2D_ROOT}/external/tiff/prebuilt/mac
|
|
|
|
${COCOS2D_ROOT}/external/webp/prebuilt/mac
|
|
|
|
${COCOS2D_ROOT}/external/freetype2/prebuilt/mac
|
|
|
|
${COCOS2D_ROOT}/external/websockets/prebuilt/mac
|
|
|
|
${COCOS2D_ROOT}/external/chipmunk/prebuilt/mac
|
|
|
|
)
|
|
|
|
endif()
|
2014-05-04 14:02:00 +08:00
|
|
|
endif()
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-10-13 16:52:14 +08:00
|
|
|
# build for 3rd party libraries
|
2014-10-15 21:33:58 +08:00
|
|
|
if(LINUX OR APPLE)
|
2014-10-13 16:52:14 +08:00
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/Box2D)
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/unzip)
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/xxhash)
|
|
|
|
add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2)
|
|
|
|
endif()
|
|
|
|
|
2014-08-24 18:52:51 +08:00
|
|
|
# libcocos2d
|
2014-05-02 06:23:20 +08:00
|
|
|
add_subdirectory(${COCOS2D_ROOT}/cocos)
|
2014-01-07 11:34:48 +08:00
|
|
|
|
2014-10-15 21:33:58 +08:00
|
|
|
if(GAME_HEADERS)
|
|
|
|
add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS})
|
|
|
|
else()
|
2014-08-24 18:52:51 +08:00
|
|
|
add_executable(${APP_NAME} ${GAME_SRC})
|
2014-10-15 21:33:58 +08:00
|
|
|
endif()
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-08-24 18:52:51 +08:00
|
|
|
target_link_libraries(${APP_NAME} cocos2d)
|
2013-11-08 18:13:24 +08:00
|
|
|
|
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}")
|
|
|
|
|
2014-05-04 14:02:00 +08:00
|
|
|
if ( WIN32 )
|
|
|
|
#also copying dlls to binary directory for the executable to run
|
|
|
|
pre_build(${APP_NAME}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
|
2014-09-13 17:50:02 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
|
2014-05-04 14:02:00 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt/glew32.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt/zlib1.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
pre_build(${APP_NAME}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
|
2014-09-13 17:50:02 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
|
2014-05-04 14:02:00 +08:00
|
|
|
)
|
2013-11-08 18:13:24 +08:00
|
|
|
|
2014-05-29 15:25:58 +08:00
|
|
|
endif()
|