2014-03-11 17:56:33 +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)
|
2014-11-17 06:42:04 +08:00
|
|
|
set(PLATFORM_SRC proj.android/jni/hellocpp/main.cpp)
|
|
|
|
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
|
|
|
|
|
|
|
set(SAMPLE_SRC
|
|
|
|
${PLATFORM_SRC}
|
|
|
|
Classes/AppDelegate.cpp
|
|
|
|
Classes/HelloWorldScene.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# add the executable
|
|
|
|
add_executable(${APP_NAME}
|
|
|
|
${SAMPLE_SRC}
|
|
|
|
)
|
|
|
|
|
2014-11-11 14:49:27 +08:00
|
|
|
target_link_libraries(${APP_NAME} cocos2d)
|
|
|
|
|
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()
|
|
|
|
|