2014-08-24 18:52:51 +08:00
|
|
|
#/****************************************************************************
|
|
|
|
# Copyright (c) 2013 cocos2d-x.org
|
|
|
|
# Copyright (c) 2014 martell malone
|
2016-03-03 08:51:54 +08:00
|
|
|
# Copyright (c) 2015 Chukong Technologies Inc.
|
2014-08-24 18:52:51 +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:
|
2014-05-02 04:01:51 +08:00
|
|
|
|
2014-08-24 18:52:51 +08:00
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
2014-05-02 04:01:51 +08:00
|
|
|
|
2014-08-24 18:52:51 +08:00
|
|
|
# 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.
|
|
|
|
# ****************************************************************************/
|
2014-05-02 04:01:51 +08:00
|
|
|
|
2014-08-24 18:52:51 +08:00
|
|
|
# this CMakeLists is to generate libcocos2d.a
|
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2014-10-15 05:19:29 +08:00
|
|
|
|
2014-09-17 11:23:59 +08:00
|
|
|
if(WINDOWS)
|
|
|
|
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
|
2014-09-10 03:18:31 +08:00
|
|
|
endif()
|
|
|
|
|
2014-09-17 11:23:59 +08:00
|
|
|
include(2d/CMakeLists.txt)
|
|
|
|
include(3d/CMakeLists.txt)
|
|
|
|
include(platform/CMakeLists.txt)
|
|
|
|
include(physics/CMakeLists.txt)
|
2015-05-08 15:49:33 +08:00
|
|
|
include(physics3d/CMakeLists.txt)
|
2014-09-17 11:23:59 +08:00
|
|
|
include(math/CMakeLists.txt)
|
2015-05-29 16:45:33 +08:00
|
|
|
include(navmesh/CMakeLists.txt)
|
2014-09-17 11:23:59 +08:00
|
|
|
include(renderer/CMakeLists.txt)
|
2016-06-16 02:33:25 +08:00
|
|
|
include(vr/CMakeLists.txt)
|
2014-09-17 11:23:59 +08:00
|
|
|
include(base/CMakeLists.txt)
|
|
|
|
include(deprecated/CMakeLists.txt)
|
|
|
|
include(ui/CMakeLists.txt)
|
|
|
|
include(network/CMakeLists.txt)
|
|
|
|
include(audio/CMakeLists.txt)
|
|
|
|
include(storage/CMakeLists.txt)
|
|
|
|
|
2014-11-14 07:25:21 +08:00
|
|
|
if(BUILD_EDITOR_COCOSBUILDER)
|
2014-09-17 11:23:59 +08:00
|
|
|
include(editor-support/cocosbuilder/CMakeLists.txt)
|
2014-11-14 07:25:21 +08:00
|
|
|
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CCB_SRC})
|
|
|
|
endif(BUILD_EDITOR_COCOSBUILDER)
|
|
|
|
|
|
|
|
if(BUILD_EDITOR_COCOSTUDIO)
|
2014-09-17 11:23:59 +08:00
|
|
|
include(editor-support/cocostudio/CMakeLists.txt)
|
2014-11-14 07:25:21 +08:00
|
|
|
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CS_SRC})
|
|
|
|
endif(BUILD_EDITOR_COCOSTUDIO)
|
|
|
|
|
|
|
|
if(BUILD_EDITOR_SPINE)
|
2014-09-17 11:23:59 +08:00
|
|
|
include(editor-support/spine/CMakeLists.txt)
|
2014-11-14 07:25:21 +08:00
|
|
|
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_SPINE_SRC})
|
|
|
|
endif(BUILD_EDITOR_SPINE)
|
2014-09-17 11:23:59 +08:00
|
|
|
|
|
|
|
include(../extensions/CMakeLists.txt)
|
|
|
|
|
|
|
|
set(COCOS_SRC cocos2d.cpp
|
|
|
|
${COCOS_2D_SRC}
|
|
|
|
${COCOS_3D_SRC}
|
|
|
|
${COCOS_PLATFORM_SRC}
|
|
|
|
${COCOS_PHYSICS_SRC}
|
2015-05-08 15:49:33 +08:00
|
|
|
${COCOS_PHYSICS3D_SRC}
|
2014-09-17 11:23:59 +08:00
|
|
|
${COCOS_MATH_SRC}
|
2015-05-29 16:45:33 +08:00
|
|
|
${COCOS_NAVMESH_SRC}
|
2014-09-17 11:23:59 +08:00
|
|
|
${COCOS_RENDERER_SRC}
|
2016-06-16 02:33:25 +08:00
|
|
|
${COCOS_VR_SRC}
|
2014-09-17 11:23:59 +08:00
|
|
|
${COCOS_BASE_SRC}
|
|
|
|
${COCOS_AUDIO_SRC}
|
|
|
|
${COCOS_UI_SRC}
|
2014-09-27 16:55:41 +08:00
|
|
|
${COCOS_DEPRECATED_SRC}
|
2014-09-17 11:23:59 +08:00
|
|
|
${COCOS_NETWORK_SRC}
|
2014-09-18 02:50:59 +08:00
|
|
|
${COCOS_EDITOR_SUPPORT_SRC}
|
|
|
|
${COCOS_EXTENSIONS_SRC}
|
2014-09-10 03:18:31 +08:00
|
|
|
)
|
|
|
|
|
2014-09-20 00:56:51 +08:00
|
|
|
#todo: provide prebuild versions of the xx libs for all platforms
|
2014-12-21 21:41:45 +08:00
|
|
|
include_directories(../external/xxtea)
|
2015-06-16 17:09:27 +08:00
|
|
|
include_directories(../external/clipper)
|
2014-09-20 00:56:51 +08:00
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
add_library(cocos2dInternal ${COCOS_SRC})
|
2014-09-20 00:56:51 +08:00
|
|
|
|
2015-10-23 07:12:37 +08:00
|
|
|
set_target_properties(cocos2dInternal
|
|
|
|
PROPERTIES
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
|
|
|
VERSION "${COCOS2D_X_VERSION}"
|
|
|
|
)
|
|
|
|
|
2014-11-18 04:44:16 +08:00
|
|
|
set(PLATFORM_SPECIFIC_LIBS)
|
|
|
|
if(WINDOWS)
|
2014-11-18 15:07:11 +08:00
|
|
|
foreach(_pkg OPENGL GLEW GLFW3 VORBIS MPG123 OPENAL)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal ${_pkg})
|
2014-11-18 04:44:16 +08:00
|
|
|
endforeach()
|
2016-08-22 15:50:17 +08:00
|
|
|
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm version)
|
2015-10-23 07:12:37 +08:00
|
|
|
if(MINGW)
|
|
|
|
list(APPEND PLATFORM_SPECIFIC_LIBS shlwapi version)
|
|
|
|
endif()
|
2014-09-17 11:23:59 +08:00
|
|
|
elseif(LINUX)
|
2016-03-03 08:51:54 +08:00
|
|
|
foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3)
|
|
|
|
cocos_use_pkg(cocos2dInternal ${_pkg})
|
2014-11-18 04:44:16 +08:00
|
|
|
endforeach()
|
2014-10-15 05:19:29 +08:00
|
|
|
elseif(MACOSX OR APPLE)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal GLFW3)
|
2014-11-20 17:05:15 +08:00
|
|
|
|
2014-09-17 11:23:59 +08:00
|
|
|
INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
|
|
|
|
|
|
|
|
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
|
|
|
FIND_LIBRARY(OPENGL_LIBRARY OpenGL )
|
|
|
|
FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox)
|
|
|
|
FIND_LIBRARY(OPENAL_LIBRARY OpenAL )
|
|
|
|
FIND_LIBRARY(QUARTZCORE_LIBRARY QuartzCore )
|
|
|
|
FIND_LIBRARY(APPLICATIONSERVICES_LIBRARY ApplicationServices)
|
|
|
|
FIND_LIBRARY(IOKIT_LIBRARY IOKit)
|
|
|
|
FIND_LIBRARY(FOUNDATION_LIBRARY Foundation)
|
2016-03-05 02:47:19 +08:00
|
|
|
FIND_LIBRARY(ICONV_LIBRARY iconv)
|
2014-09-17 11:23:59 +08:00
|
|
|
|
|
|
|
set(PLATFORM_SPECIFIC_LIBS
|
|
|
|
${COCOA_LIBRARY}
|
|
|
|
${OPENGL_LIBRARY}
|
|
|
|
${OPENAL_LIBRARY}
|
|
|
|
${AUDIOTOOLBOX_LIBRARY}
|
|
|
|
${QUARTZCORE_LIBRARY}
|
|
|
|
${APPLICATIONSERVICES_LIBRARY}
|
|
|
|
${IOKIT_LIBRARY}
|
|
|
|
${FOUNDATION_LIBRARY}
|
2016-03-05 02:47:19 +08:00
|
|
|
${ICONV_LIBRARY}
|
2014-09-17 11:23:59 +08:00
|
|
|
)
|
2014-09-10 03:18:31 +08:00
|
|
|
|
2014-09-20 08:46:39 +08:00
|
|
|
elseif(ANDROID)
|
2016-03-03 08:51:54 +08:00
|
|
|
set(PLATFORM_SPECIFIC_LIBS GLESv1_CM GLESv2 EGL log android OpenSLES)
|
|
|
|
get_filename_component(__module_path "${CMAKE_TOOLCHAIN_FILE}" DIRECTORY)
|
|
|
|
include(${__module_path}/AndroidNdkModules.cmake)
|
|
|
|
android_ndk_import_module_cpufeatures()
|
2014-09-10 03:18:31 +08:00
|
|
|
else()
|
|
|
|
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
|
|
|
|
endif()
|
|
|
|
|
2017-01-19 13:55:14 +08:00
|
|
|
foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL OPENSSL FLATBUFFERS XXHASH)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal ${pkg})
|
2014-11-19 05:27:25 +08:00
|
|
|
endforeach()
|
2014-11-16 02:16:39 +08:00
|
|
|
|
2015-03-05 16:34:51 +08:00
|
|
|
if(LINUX)
|
|
|
|
set(glfw_other_linker_flags X11)
|
2015-03-05 17:05:08 +08:00
|
|
|
endif(LINUX)
|
2015-03-05 16:34:51 +08:00
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
target_link_libraries(cocos2dInternal ${PLATFORM_SPECIFIC_LIBS} ${glfw_other_linker_flags})
|
2014-11-18 04:44:16 +08:00
|
|
|
|
2014-11-15 16:31:10 +08:00
|
|
|
if(USE_WEBP)
|
|
|
|
add_definitions(-DCC_USE_WEBP=1)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal WEBP)
|
2014-11-15 16:31:10 +08:00
|
|
|
else()
|
|
|
|
add_definitions(-DCC_USE_WEBP=0)
|
|
|
|
endif()
|
2014-08-24 18:52:51 +08:00
|
|
|
|
2014-11-15 18:17:23 +08:00
|
|
|
if(USE_CHIPMUNK)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal CHIPMUNK)
|
2014-11-15 18:17:23 +08:00
|
|
|
endif()
|
|
|
|
|
2014-11-15 22:46:13 +08:00
|
|
|
if(USE_BOX2D)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal Box2D)
|
2014-11-15 22:46:13 +08:00
|
|
|
endif()
|
|
|
|
|
2015-05-08 15:49:33 +08:00
|
|
|
if(USE_BULLET)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal BULLET)
|
2015-05-08 15:49:33 +08:00
|
|
|
endif()
|
|
|
|
|
2015-05-29 16:45:33 +08:00
|
|
|
if(USE_RECAST)
|
2016-03-03 08:51:54 +08:00
|
|
|
cocos_use_pkg(cocos2dInternal RECAST)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ADD_LIBRARY(cocos2d cc_dummy.c)
|
|
|
|
|
|
|
|
if(ANDROID)
|
|
|
|
target_link_libraries(cocos2d -Wl,-whole-archive cocos2dxandroid_static -Wl,-no-whole-archive)
|
|
|
|
target_link_libraries(cocos2d cocos2dInternal cpufeatures)
|
2017-01-19 13:55:14 +08:00
|
|
|
elseif(LINUX)
|
|
|
|
target_link_libraries(cocos2d cocos2dInternal dl)
|
2016-03-03 08:51:54 +08:00
|
|
|
else()
|
|
|
|
target_link_libraries(cocos2d cocos2dInternal)
|
2015-05-29 16:45:33 +08:00
|
|
|
endif()
|
|
|
|
|
2014-05-02 04:01:51 +08:00
|
|
|
set_target_properties(cocos2d
|
|
|
|
PROPERTIES
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
2014-09-21 23:49:43 +08:00
|
|
|
VERSION "${COCOS2D_X_VERSION}"
|
2014-05-02 04:01:51 +08:00
|
|
|
)
|