HelloCpp works.

This commit is contained in:
James Chen 2013-11-02 16:31:52 +08:00
parent 8676523433
commit e560de6e4e
5 changed files with 63 additions and 17 deletions

View File

@ -5,13 +5,16 @@ project (Cocos2dxSamples)
set(Cocos2dxSamples_VERSION_MAJOR 3)
set(Cocos2dxSamples_VERSION_MINOR 0)
add_definitions(-DLINUX)
include(build/BuildHelpers.CMakeLists.txt)
# debug
message( "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" )
add_definitions(-D_DEBUG)
endif()
set(CMAKE_BUILE_TYPE DEBUG)
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")
add_definitions(-DLINUX)
# architecture
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
@ -20,9 +23,6 @@ else()
set(ARCH_DIR "32-bit")
endif()
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99")
include_directories(
cocos/2d
cocos/2d/platform
@ -73,8 +73,6 @@ add_subdirectory(cocos/math/kazmath)
# chipmunk library
set(BUILD_STATIC 1)
# chipmunk library
add_subdirectory(external/chipmunk/src)
# unzip library
@ -86,12 +84,9 @@ add_subdirectory(external/tinyxml2)
# cocos base library
add_subdirectory(cocos/base)
# cocos physics sources
#add_subdirectory(cocos/physics)
# cocos 2d library
add_subdirectory(cocos/2d)
# sample HelloCpp
add_subdirectory(samples/Cpp/HelloCpp)
# build samples
add_subdirectory(samples)

View File

@ -0,0 +1,37 @@
# Copies files for the given game into the target res directory
# GAME_NAME name of the game
# REL_DIR to which directory these files are relative
# SRC_FILES which files from the REL_DIR to copy (GLOB)
macro(COPY_RES_FILES GAME_NAME GAME_RES_TARGET REL_DIR SRC_FILES DST)
file( GLOB_RECURSE RES_FILES RELATIVE ${REL_DIR} ${SRC_FILES} )
set(ALL_FILES)
foreach(SRC_FILE ${RES_FILES})
add_custom_command(
OUTPUT "${DST}/${SRC_FILE}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${REL_DIR}/${SRC_FILE}"
"${DST}/${SRC_FILE}"
COMMENT "Copy ${SRC_FILE}"
)
list(APPEND ALL_FILES "${DST}/${SRC_FILE}" )
endforeach()
# create target for copying these files
add_custom_target( ${GAME_RES_TARGET} DEPENDS ${ALL_FILES} )
endmacro()
# convenience to call above with current directory and everything in "res"
macro(COPY_RES GAME_NAME CRG_PATTERN DST)
# a target for all addition asserts (will be done in default compile, but if you target the executable
# it won't be done -- good for testing)
add_custom_target( ${GAME_NAME}_ASSETS ALL )
COPY_RES_FILES( ${GAME_NAME} ${GAME_NAME}_CORE_RES
${CMAKE_CURRENT_SOURCE_DIR}
"${CRG_PATTERN}"
${DST}
)
add_dependencies( ${GAME_NAME}_ASSETS ${GAME_NAME}_CORE_RES )
endmacro()

View File

@ -49,7 +49,7 @@ bool FileUtilsLinux::init()
fullpath[length] = '\0';
std::string appPath = fullpath;
_defaultResRootPath = appPath.substr(0, appPath.find_last_of("/"));
_defaultResRootPath += "/../../../Resources/";
_defaultResRootPath += "/Resources/";
// Set writable path to $XDG_CONFIG_HOME or ~/.config/<app name>/ if $XDG_CONFIG_HOME not exists.
const char* xdg_config_path = getenv("XDG_CONFIG_HOME");

4
samples/CMakeLists.txt Normal file
View File

@ -0,0 +1,4 @@
add_subdirectory(Cpp/HelloCpp)
add_subdirectory(Cpp/TestCpp)

View File

@ -12,3 +12,13 @@ add_executable(${SAMPLE_NAME}
)
target_link_libraries(${SAMPLE_NAME} ${COCOS_LIBRARIES})
set(SAMPLE_BIN_DIR ${CMAKE_BINARY_DIR}/bin)
SET_TARGET_PROPERTIES(${SAMPLE_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${SAMPLE_BIN_DIR}/HelloCpp")
message(STATUS "Hello.........." ${CMAKE_BINARY_DIR})
COPY_RES( ${SAMPLE_NAME} "Resources/*" "${SAMPLE_BIN_DIR}/HelloCpp")