2016-03-03 08:51:54 +08:00
|
|
|
#/****************************************************************************
|
|
|
|
# Copyright (c) 2015 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.
|
|
|
|
# ****************************************************************************/
|
|
|
|
|
2016-05-14 08:49:39 +08:00
|
|
|
set(APP_NAME cpp-empty-test)
|
2014-03-10 20:07:20 +08:00
|
|
|
|
2014-08-06 22:43:19 +08:00
|
|
|
if(ANDROID)
|
2016-03-03 08:51:54 +08:00
|
|
|
set(PLATFORM_SRC proj.android/jni/main.cpp)
|
2014-11-17 06:42:04 +08:00
|
|
|
set(RES_PREFIX "/Resources")
|
2014-08-06 22:43:19 +08:00
|
|
|
elseif(WINDOWS)
|
2014-11-17 06:42:04 +08:00
|
|
|
set(PLATFORM_SRC proj.win32/main.cpp)
|
|
|
|
set(RES_PREFIX "")
|
2014-08-06 22:43:19 +08:00
|
|
|
elseif(IOS)
|
|
|
|
set(PLATFORM_SRC
|
|
|
|
proj.ios/main.m
|
|
|
|
proj.ios/AppController.mm
|
|
|
|
proj.ios/RootViewController.mm
|
|
|
|
)
|
|
|
|
|
2014-10-15 05:19:29 +08:00
|
|
|
elseif(MACOSX OR APPLE)
|
2014-11-17 06:42:04 +08:00
|
|
|
set(PLATFORM_SRC proj.mac/main.cpp)
|
2014-08-06 22:43:19 +08:00
|
|
|
|
2014-11-11 14:49:27 +08:00
|
|
|
file(GLOB_RECURSE RES_FILES Resources/*)
|
|
|
|
cocos_mark_resources(FILES ${RES_FILES} BASEDIR Resources)
|
|
|
|
list(APPEND PLATFORM_SRC ${RES_FILES})
|
|
|
|
|
2014-08-06 22:43:19 +08:00
|
|
|
elseif(LINUX)
|
2014-11-17 06:42:04 +08:00
|
|
|
set(PLATFORM_SRC proj.linux/main.cpp)
|
|
|
|
set(RES_PREFIX "/Resources")
|
2014-09-10 03:18:31 +08:00
|
|
|
else()
|
|
|
|
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
|
|
|
|
|
2014-08-06 22:43:19 +08:00
|
|
|
endif()
|
2014-03-10 20:07:20 +08:00
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
include_directories(Classes)
|
|
|
|
|
2014-03-10 20:07:20 +08:00
|
|
|
set(SAMPLE_SRC
|
|
|
|
${PLATFORM_SRC}
|
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
|
|
|
)
|
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
if(ANDROID)
|
|
|
|
add_library(${APP_NAME} SHARED ${SAMPLE_SRC})
|
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES RELEASE)
|
|
|
|
ADD_CUSTOM_COMMAND(TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} lib${APP_NAME}.so)
|
|
|
|
ENDIF()
|
|
|
|
else()
|
|
|
|
# add the executable
|
|
|
|
add_executable(${APP_NAME} ${SAMPLE_SRC})
|
|
|
|
endif()
|
2014-03-10 20:07:20 +08:00
|
|
|
|
2014-11-11 14:49:27 +08:00
|
|
|
target_link_libraries(${APP_NAME} cocos2d)
|
|
|
|
|
2016-03-03 08:51:54 +08:00
|
|
|
|
2014-08-06 22:43:19 +08:00
|
|
|
if(MSVC)
|
|
|
|
|
2014-03-10 20:07:20 +08:00
|
|
|
#get our resources
|
|
|
|
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
#get our dlls
|
|
|
|
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
2014-09-30 04:08:41 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../../external/win32-specific/gles/prebuilt/glew32.dll
|
2014-03-10 20:07:20 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
2014-09-30 04:08:41 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../../external/win32-specific/zlib/prebuilt/zlib1.dll
|
2014-03-10 20:07:20 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Debug)
|
|
|
|
|
|
|
|
#Visual Studio Defaults to wrong type
|
|
|
|
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
|
|
|
|
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
2014-08-06 22:43:19 +08:00
|
|
|
|
2014-11-11 14:49:27 +08:00
|
|
|
elseif(MACOSX OR APPLE)
|
|
|
|
set_target_properties(${APP_NAME} PROPERTIES
|
|
|
|
MACOSX_BUNDLE 1
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
|
|
|
)
|
|
|
|
|
2014-03-10 20:07:20 +08:00
|
|
|
else()
|
2014-08-06 22:43:19 +08:00
|
|
|
|
2014-03-10 20:07:20 +08:00
|
|
|
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}")
|
|
|
|
|
|
|
|
set_target_properties(${APP_NAME} PROPERTIES
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
2014-11-11 14:49:27 +08:00
|
|
|
add_custom_command(TARGET ${APP_NAME} POST_BUILD
|
2014-11-17 06:42:04 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources $<TARGET_FILE_DIR:${APP_NAME}>${RES_PREFIX}
|
2014-03-10 20:07:20 +08:00
|
|
|
)
|
2014-09-10 03:18:31 +08:00
|
|
|
|
2014-03-10 20:07:20 +08:00
|
|
|
endif()
|
|
|
|
|