mirror of https://github.com/axmolengine/axmol.git
143 lines
5.5 KiB
CMake
143 lines
5.5 KiB
CMake
#/****************************************************************************
|
|
# Copyright (c) 2013-2014 cocos2d-x.org
|
|
#
|
|
# 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.
|
|
# ****************************************************************************/
|
|
cmake_policy(SET CMP0017 NEW)
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
set(APP_NAME HelloLua)
|
|
project (${APP_NAME})
|
|
|
|
set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d-x)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_ROOT}/cmake/Modules/")
|
|
include(CocosBuildHelpers)
|
|
|
|
option(DEBUG_MODE "Debug or release?" ON)
|
|
option(USE_BULLET "Use bullet for physics3d library" ON)
|
|
|
|
if(DEBUG_MODE)
|
|
set(CMAKE_BUILD_TYPE DEBUG)
|
|
else(DEBUG_MODE)
|
|
set(CMAKE_BUILD_TYPE RELEASE)
|
|
endif(DEBUG_MODE)
|
|
|
|
if(USE_BULLET)
|
|
add_definitions(-DCC_ENABLE_BULLET_INTEGRATION=1)
|
|
add_definitions(-DCC_USE_PHYSICS=1)
|
|
endif(USE_BULLET)
|
|
|
|
|
|
# libcocos2d
|
|
set(BUILD_CPP_EMPTY_TEST OFF CACHE BOOL "turn off build cpp-empty-test")
|
|
set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests")
|
|
set(BUILD_LUA_TESTS OFF CACHE BOOL "turn off build lua-tests")
|
|
set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js related targets")
|
|
add_subdirectory(${COCOS2D_ROOT})
|
|
|
|
|
|
# Some macro definitions
|
|
if(WINDOWS)
|
|
if(BUILD_SHARED_LIBS)
|
|
ADD_DEFINITIONS (-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL)
|
|
else()
|
|
ADD_DEFINITIONS (-DCC_STATIC)
|
|
endif()
|
|
|
|
ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32)
|
|
set(PLATFORM_FOLDER win32)
|
|
elseif(MACOSX OR APPLE)
|
|
ADD_DEFINITIONS (-DCC_TARGET_OS_MAC)
|
|
ADD_DEFINITIONS (-DUSE_FILE32API)
|
|
set(PLATFORM_FOLDER mac)
|
|
elseif(LINUX)
|
|
ADD_DEFINITIONS(-DLINUX)
|
|
set(PLATFORM_FOLDER linux)
|
|
elseif(ANDROID)
|
|
ADD_DEFINITIONS (-DUSE_FILE32API)
|
|
set(PLATFORM_FOLDER android)
|
|
else()
|
|
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
|
|
endif()
|
|
|
|
|
|
# Compiler options
|
|
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})
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
|
|
if(CLANG)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
|
endif()
|
|
endif(MSVC)
|
|
|
|
set(GAME_SRC
|
|
runtime-src/proj.linux/main.cpp
|
|
runtime-src/Classes/AppDelegate.cpp
|
|
)
|
|
|
|
|
|
include_directories(
|
|
/usr/include
|
|
/usr/include/GLFW
|
|
/usr/local/include/GLFW
|
|
runtime-src/Classes
|
|
${COCOS2D_ROOT}/cocos
|
|
${COCOS2D_ROOT}/cocos/scripting/lua-bindings/manual
|
|
${COCOS2D_ROOT}/external/lua/lua
|
|
${COCOS2D_ROOT}/external/
|
|
${COCOS2D_ROOT}/external/lua/tolua
|
|
${COCOS2D_ROOT}/cocos/audio/include
|
|
)
|
|
|
|
# add the executable
|
|
add_executable(${APP_NAME} ${GAME_SRC})
|
|
|
|
target_link_libraries(${APP_NAME} cocos2d luacocos2d)
|
|
|
|
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
|
|
|
|
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}/../res ${APP_BIN_DIR}/Resources/res
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}/Resources/src
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/cocos2d ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/cocosdenshion ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/cocosbuilder ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/cocostudio ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/extension ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/network ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/ui ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/3d ${APP_BIN_DIR}/Resources
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/physics3d ${APP_BIN_DIR}/Resources
|
|
)
|
|
|