Hi all id like to port to cocos2dx V4 and its not too much trouble but want to keep support for V 3.17.2
I see this for target build but is there one for the Version’s of Cocos 3.17.2 detection
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
many thanks in advance.
also not sounding too silly was compiling for win32 theirs no WebView is there still and inbuilt browser for
Cocos or we just launching Internet explore external.
I don’t understand why you want to do this. Can you explain more of your use case?
Are you trying to keep the same code base and have v3 and v4 specific functionality?
Perhaps you can check the version of Cocos being used by using this:
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
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
This file has been truncated. show original
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
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
This file has been truncated. show original
R101
April 8, 2021, 2:06pm
#3
Certain sections of the CMakeLists.txt will be differnet between v3.17.2 and v4, so use this to get the version:
get_target_property(COCOS2D_X_VERSION cocos2d VERSION)
For instance:
get_target_property(COCOS2D_X_VERSION cocos2d VERSION)
if (COCOS2D_X_VERSION VERSION_GREATER_EQUAL 4.0.0)
if(APPLE)
set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
if(MACOSX)
set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist")
elseif(IOS)
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")
set_xcode_property(${APP_NAME} XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") # iphone, ipad
set_target_properties(${APP_NAME} PROPERTIES
XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] x86_64
XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] x86_64
)
endif()
# For code-signing, set the DEVELOPMENT_TEAM:
#set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9") # requires 10 digit identifier
#set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer")
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
#SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 11.0)
endif()
SET (CMAKE_XCODE_ATTRIBUTE_PRODUCT_NAME "ProductName")
SET (CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY 1,2)
target_link_libraries(${APP_NAME} PRIVATE "-framework MediaPlayer")
elseif(WINDOWS)
cocos_copy_target_dll(${APP_NAME})
endif()
if(LINUX OR WINDOWS)
set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
add_custom_command(TARGET ${APP_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${GAME_RES_FOLDER} ${APP_RES_DIR})
endif()
# if(LINUX OR WINDOWS)
# cocos_get_resource_path(APP_RES_DIR ${APP_NAME})
# cocos_copy_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
# endif()
elseif(COCOS2D_X_VERSION VERSION_GREATER_EQUAL 3.17.2)
if(APPLE)
set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
if(MACOSX)
set_target_properties(${APP_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist"
)
elseif(IOS)
cocos_pak_xcode(${APP_NAME} INFO_PLIST "iOSBundleInfo.plist.in")
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")
set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer")
endif()
elseif(WINDOWS)
cocos_copy_target_dll(${APP_NAME})
endif()
if(LINUX OR WINDOWS)
set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
add_custom_command(TARGET ${APP_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${GAME_RES_FOLDER} ${APP_RES_DIR})
endif()
# if(LINUX OR WINDOWS)
# set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
# cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
# endif()
else()
if(APPLE)
set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
if(MACOSX)
set_target_properties(${APP_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist"
)
elseif(IOS)
cocos_pak_xcode(${APP_NAME} INFO_PLIST "iOSBundleInfo.plist.in")
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
endif()
elseif(WINDOWS)
cocos_copy_target_dll(${APP_NAME} COPY_TO ${APP_RES_DIR}/..)
endif()
if(LINUX OR WINDOWS)
cocos_copy_res(COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
endif()
endif()
1 Like
R101:
CMakeLists.txt
Thanks yeah did not think to look in the CMakeLists it’s all there, lol its cos I have been using Xcode for a long while and I’m now using android studio forgot need to edit that file now Many thanks.
R101
April 8, 2021, 10:47pm
#5
You will still need to use the COCOS2D_VERSION
define from cocos2d.h to handle differences in your source code (check the post above by @slackmoehrle ). The only alternative to this is creating your own version definition in the CMakeLists.txt
, and passing that to the compiler.
The main differences between 3.17.2 and 4.0 will be related to the rendering and shader code, such as cocos2d::GLProgramState
in 3.17.2 and cocos2d::backend::ProgramState
in 4.0.
1 Like
system
closed
April 9, 2021, 10:48pm
#6
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.