From 0dd2db26276eb8189a92022103381fdde86f063e Mon Sep 17 00:00:00 2001 From: badlogic Date: Mon, 3 Feb 2020 14:57:29 +0100 Subject: [PATCH 1/2] [cocos2dx] Improve CMake build for cocos2d-x v3 and v4 example projects, based on PR #1572. --- spine-cocos2dx/example-v4/CMakeLists.txt | 4 +- spine-cocos2dx/example/CMakeLists.txt | 60 +++++------------------- 2 files changed, 13 insertions(+), 51 deletions(-) diff --git a/spine-cocos2dx/example-v4/CMakeLists.txt b/spine-cocos2dx/example-v4/CMakeLists.txt index ffc13c822..92feba7a9 100644 --- a/spine-cocos2dx/example-v4/CMakeLists.txt +++ b/spine-cocos2dx/example-v4/CMakeLists.txt @@ -152,9 +152,9 @@ if(APPLE) set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}") if(MACOSX) - set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist") + set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist") elseif(IOS) - set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist") + set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist") set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon") endif() diff --git a/spine-cocos2dx/example/CMakeLists.txt b/spine-cocos2dx/example/CMakeLists.txt index cf83334eb..8fd7aa87c 100644 --- a/spine-cocos2dx/example/CMakeLists.txt +++ b/spine-cocos2dx/example/CMakeLists.txt @@ -26,21 +26,23 @@ cmake_minimum_required(VERSION 3.8) -set(APP_NAME MyGame) +set(APP_NAME spine-cocos2dx-example) project (${APP_NAME}) set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_ROOT}/cmake/Modules/") -include(CocosConfigDefine) -include(CocosBuildHelpers) +set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d) +set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) # libcocos2d -set(BUILD_CPP_EMPTY_TEST OFF CACHE BOOL "turn off build cpp-empty-test") -set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests") -set(BUILD_LUA_LIBS OFF CACHE BOOL "turn off build lua related targets") -set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js related targets") +set(BUILD_CPP_EMPTY_TEST OFF CACHE BOOL "turn off build cpp-empty-test" FORCE) +set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests" FORCE) +set(BUILD_LUA_LIBS OFF CACHE BOOL "turn off build lua related targets" FORCE) +set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js related targets" FORCE) + +set(BUILD_EDITOR_SPINE OFF CACHE BOOL "Build editor support for spine" FORCE) set(BUILD_EDITOR_SPINE ON CACHE BOOL "enable spine") @@ -50,52 +52,12 @@ include_directories( ${CMAKE_CURRENT_LIST_DIR}/../src ) -add_subdirectory(${COCOS2D_ROOT}) +include(CocosBuildSet) +add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core) get_target_property(COCOS2D_X_VERSION cocos2d VERSION) set(COCOS2DX_ROOT_PATH ${COCOS2D_ROOT}) -# Some macro definitions -# if(WINDOWS) -# if(BUILD_SHARED_LIBS) -# ADD_DEFINITIONS (-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL) -# else() -# ADD_DEFINITIONS (-DCC_STATIC) -# endif() - -# ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32) -# set(PLATFORM_FOLDER win32) -# elseif(MACOSX OR APPLE) -# ADD_DEFINITIONS (-DCC_TARGET_OS_MAC) -# ADD_DEFINITIONS (-DUSE_FILE32API) -# set(PLATFORM_FOLDER mac) -# elseif(LINUX) -# ADD_DEFINITIONS(-DLINUX) -# set(PLATFORM_FOLDER linux) -# elseif(ANDROID) -# ADD_DEFINITIONS (-DUSE_FILE32API) -# set(PLATFORM_FOLDER android) -# else() -# message( FATAL_ERROR "Unsupported platform, CMake will exit" ) -# endif() - - -# Compiler options -# if(MSVC) -# ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -# -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 -# -wd4514 -wd4056 -wd4996 -wd4099) -# else() -# 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 -Wno-deprecated-declarations -Wno-reorder") -# if(CLANG) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") -# endif() -# endif(MSVC) - - set(PLATFORM_SPECIFIC_SRC) set(PLATFORM_SPECIFIC_HEADERS) set(cc_common_res) From 90c2a19364efac91fac4064a4b6b0e5f10250606 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 3 Feb 2020 15:52:50 +0100 Subject: [PATCH 2/2] [cocos2dx] Updated windows build for cocos2d-x v4. --- spine-cocos2dx/README.md | 3 +++ spine-cocos2dx/example-v4/CMakeLists.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/spine-cocos2dx/README.md b/spine-cocos2dx/README.md index cc44d8c43..765caa3ae 100644 --- a/spine-cocos2dx/README.md +++ b/spine-cocos2dx/README.md @@ -87,6 +87,7 @@ Please note the [new prerequisits to compile Cocos2d-x v4 projects on different #### Windows 1. Install [Visual Studio 2019 Community](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) 2. Install CMake via the [Windows installer package](https://cmake.org/download/). +3. Install Python and make sure the `python.exe` is in your `PATH` environment variable. Python is required by cocos2d-x`s build system. 3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above. 4. Run CMake GUI from the start menu 5. Click `Browse Source` and select the directory `spine-runtimes` @@ -98,6 +99,8 @@ Please note the [new prerequisits to compile Cocos2d-x v4 projects on different 9. Right click the `spine-cocos2dx-example` project in the solution explorer and select `Set as Startup Project` from the context menu 10. Click `Local Windows Debugger` to run the example +Make sure to build the example for Windows 32-bit! + #### macOS 1. Install [Xcode](https://developer.apple.com/xcode/) 2. Install [Homebrew](http://brew.sh/) diff --git a/spine-cocos2dx/example-v4/CMakeLists.txt b/spine-cocos2dx/example-v4/CMakeLists.txt index 92feba7a9..d98b28dcc 100644 --- a/spine-cocos2dx/example-v4/CMakeLists.txt +++ b/spine-cocos2dx/example-v4/CMakeLists.txt @@ -29,6 +29,7 @@ set(APP_NAME spine-cocos2dx-example) project(${APP_NAME}) set(BUILD_EDITOR_SPINE OFF CACHE BOOL "Build editor support for spine" FORCE) +set(BUILD_EXTENSIONS OFF CACHE BOOL "Build extensions" FORCE) if(XCODE) if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)