-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
168 lines (139 loc) · 6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#/****************************************************************************
# Copyright (c) 2014 Chukong Technologies Inc.
#
# 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_minimum_required(VERSION 2.6)
set(APP_NAME MyGame)
project (${APP_NAME})
include(frameworks/js-bindings/cocos2d-x/cmake/BuildHelpers.CMakeLists.txt)
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})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
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)
ADD_DEFINITIONS(-DCC_RESOURCE_FOLDER_LINUX="/")
# architecture
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(ARCH_DIR "64-bit")
else()
set(ARCH_DIR "32-bit")
endif()
set(GAME_SRC
frameworks/runtime-src/proj.linux/main.cpp
frameworks/runtime-src/Classes/AppDelegate.cpp
)
set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x)
include_directories(
/usr/local/include/GLFW
${COCOS2D_ROOT}
${COCOS2D_ROOT}/cocos
${COCOS2D_ROOT}/cocos/base
${COCOS2D_ROOT}/cocos/audio/include
${COCOS2D_ROOT}/cocos/platform
${COCOS2D_ROOT}/cocos/platform/desktop
${COCOS2D_ROOT}/cocos/platform/linux
${COCOS2D_ROOT}/cocos/editor-support
${COCOS2D_ROOT}/extensions
${COCOS2D_ROOT}/external
${COCOS2D_ROOT}/external/edtaa3func
${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
${COCOS2D_ROOT}/external/websockets/include/linux
${COCOS2D_ROOT}/external/spidermonkey/include/linux
${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR}
${COCOS2D_ROOT}/external/xxhash
${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/external/spidermonkey/include/linux
${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/bindings/auto
${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/bindings/manual
)
link_directories(
/usr/local/lib
${COCOS2D_ROOT}/external/chipmunk/prebuilt/linux/${ARCH_DIR}
${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}
${COCOS2D_ROOT}/external/websockets/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/spidermonkey/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/external/spidermonkey/prebuilt/linux/${ARCH_DIR}
)
# build for 3rd party libraries
if(LINUX OR APPLE)
add_subdirectory(frameworks/js-bindings/cocos2d-x/external/Box2D)
add_subdirectory(frameworks/js-bindings/cocos2d-x/external/unzip)
add_subdirectory(frameworks/js-bindings/cocos2d-x/external/xxhash)
add_subdirectory(frameworks/js-bindings/cocos2d-x/external/tinyxml2)
add_subdirectory(frameworks/js-bindings/cocos2d-x/external/protobuf-lite)
endif()
# cocos2d
add_subdirectory(${COCOS2D_ROOT}/cocos)
#jsbindings library
add_subdirectory(frameworks/js-bindings/bindings)
# 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}
jsbindings
cocos2d
js_static
)
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}/script
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/res
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/src
COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}/*.js
COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}/*.json
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/res ${APP_BIN_DIR}/res
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${APP_BIN_DIR}/src
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/bindings/script ${APP_BIN_DIR}/script
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.js ${APP_BIN_DIR}/main.js
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/project.json ${APP_BIN_DIR}/project.json
)