Skip to content

Commit 43dab73

Browse files
committed
Merge commit '8fc3b7b4064b107d85c15a4895d08e9ad335b5a8' into scgamex-v3
* commit '8fc3b7b4064b107d85c15a4895d08e9ad335b5a8': (43 commits) update change log, "allow cleartext HTTP traffic" don't include template Add Android P cutout area support (cocos2d#19286) refine cmake, allow developer switch Debug/Release in IDE (cocos2d#19329) refine cmake, add iOS sign config (cocos2d#19327) cmake support set iOS Deployment Target for root project (cocos2d#19315) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19320) Ui video player new style looping input options (cocos2d#19297) ReFix bug: PremultipliedAlpha is not working for png (cocos2d#19138) Add clear request and responses method to httpclient (cocos2d#19294) revert ndk-build final target, others need it (cocos2d#19296) Fix for COCOS2D_DEBUG is always 1 on Android (cocos2d#19291) update 3rd libs & console, fix file issues (cocos2d#19284) Install ninja (cocos2d#19298) [3rd-libs] upgrade to version 154 (cocos2d#19282) Ability to get low coupling inheritance (cocos2d#19276) cmake win32 Precompiled header (cocos2d#19273) fix spritecache plist parsing issue (cocos2d#19269) standardize pause & resume logic on GLSurfaceView (cocos2d#19256) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19267) update versoin code (cocos2d#19265) ... # Conflicts: # cocos/network/WebSocket.cpp # cocos/platform/android/CCFileUtils-android.cpp # cocos/scripting/js-bindings/CMakeLists.txt # cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_video_auto_api.js # cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp # cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp # cocos/scripting/js-bindings/manual/ScriptingCore.cpp # cocos/scripting/lua-bindings/auto/api/VideoPlayer.lua # cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp # cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp # cocos/scripting/lua-bindings/manual/CCLuaStack.cpp # cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.cpp # cocos/scripting/lua-bindings/proj.android/CMakeLists.txt # templates/js-template-default/CMakeLists.txt # templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp # templates/js-template-default/frameworks/runtime-src/proj.android/app/jni/Android.mk # templates/lua-template-default/CMakeLists.txt # templates/lua-template-default/frameworks/runtime-src/proj.android/app/jni/Android.mk # tests/game-controller-test/Classes/GameControllerTest.cpp # tests/js-tests/project/CMakeLists.txt # tests/js-tests/project/Classes/AppDelegate.cpp # tests/js-tests/project/proj.android/app/AndroidManifest.xml # tests/js-tests/src/tests-main.js # tests/lua-empty-test/project/CMakeLists.txt # tests/lua-empty-test/project/Classes/AppDelegate.cpp # tests/lua-empty-test/project/proj.android/app/AndroidManifest.xml # tests/lua-game-controller-test/project/Classes/AppDelegate.cpp # tests/lua-game-controller-test/project/proj.android/app/AndroidManifest.xml # tests/lua-tests/project/CMakeLists.txt # tests/lua-tests/project/proj.android/app/AndroidManifest.xml # tests/lua-tests/project/proj.android/app/proguard-rules.pro # tests/lua-tests/src/EffectsTest/EffectsTest.lua # tests/lua-tests/src/ParticleTest/ParticleTest.lua # tests/lua-tests/src/SpriteTest/SpriteTest.lua # tests/lua-tests/src/TransitionsTest/TransitionsTest.lua # tests/lua-tests/src/WebViewTest/WebViewTest.lua # tests/lua-tests/src/mainMenu.lua # tests/performance-tests/Classes/tests/BaseTest.cpp # tools/cocos2d-console
2 parents a897280 + 8fc3b7b commit 43dab73

File tree

81 files changed

+1500
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1500
-465
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,6 @@ tests/*/project/proj.android/.settings/org.eclipse.buildship.core.prefs
182182
# tmp folder for temp usage
183183
tmp/
184184
temp/
185+
186+
# external libs zip
187+
*.zip

CHANGELOG

+13-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ cocos2d-x-3.17.1 Nov.19 2018
1818
[REFINE] Action: add ui::LoadingBar support to Progress actions
1919
[REFINE] Network: support multiple parameters in SocketIO emit/send method
2020
[REFINE] FileUtils: improve thread safety (use single recursive_mutex)
21-
[REFINE] FileUitils: add getFileSize impl for Windows
21+
[REFINE] FileUtils: add getFileSize impl for Windows
2222
[REFINE] FileUtils: add listFiles impl for Android and Windows platform
23+
[REFINE] FileUtils: exact fullPathForDirectory from fullPathForFilename, fullPathForFilename should not accept directory
2324
[REFINE] CMake: improve libraries link, compile options config
2425
[REFINE] CMake: remove un-elegant prebuilt feature at internal cmake build scripts
2526
[REFINE] 3rd: upgrade libwebsockets to 2.4.2 with libuv enabled
2627
[REFINE] 3rd: improve cmake build scripts for external libs
28+
[REFINE] 3rd: upgrade luajit to 2.1.0-beta3, fix random crash in Android release mode
29+
[REFINE] 3rd: external/lua/lua is not referenced in cmake and it will be removed in the near future
2730
[REFINE] Tests: add websocket latency test
2831
[REFINE] Tests: add download multi task test case
32+
[REFINE] Tests: improve part test cases UI shows
2933
[REFINE] cocos console: disable "gen-libs" command
3034
[REFINE] Others: add another xbox 360 configuration
3135
[REFINE] Others: remove ANT_ROOT env check on setup.py
@@ -46,30 +50,36 @@ cocos2d-x-3.17.1 Nov.19 2018
4650
[FIX] UI: fix not support sprite frame when ignoreContentAdaptWithSize is false
4751
[FIX] UI: fix out of range access in Label
4852
[FIX] UI: fix Widget::getAncestorWidget error
49-
[FIX] UI: fix "known incorrect sRGB profile" by mogrify convert png format
5053
[FIX] UI: fix iOS editbox EndAction wrong when single line mode (UITextField)
5154
[FIX] UI: Fix for Label and UIRichEdit text trailing space trimming
55+
[FXI] JavaScript: fix crash if garbage collection runs between TouchStart and TouchEnd event
5256
[FIX] Audio: fix AudioEngine rotateBufferThread crash on iOS
5357
[FIX] Audio: add extra init checks in pcm audio service, avoid crash in PcmAudioService
5458
[FIX] Audio: fix AVAudioSessionErrorCodeCannotStartPlaying error may occur on Apple
5559
[FIX] Audio: fix background music may resumes even the application is on the background on Android
60+
[FIX] Audio: fix AudioCache* holding invalid pointer value
5661
[FIX] Network: fix memory leaks in WebSocket
5762
[FIX] Network: fix websocket memory zereoing size error
5863
[FIX] Network: fix https downloader timeout on win/mac
5964
[FIX] Network: fix "cc.loader.load" convert url error
6065
[FIX] iOS: fix project build warnings in Xcode
6166
[FIX] iOS: fix crash when saving gray colorspace image
67+
[FIX] iOS: `js/lua tests` fix double free issue on app exits.
6268
[FIX] Android: shorten C++ build path, reduce long path error on Windows
6369
[FIX] Android: keep cocos2dx activity at task root by mark "singleTask" in manifest
6470
[FIX] Android: fix crash caused by JNIEnv null pointer in getStringUTFCharsJNI function
6571
[FIX] Android: use 'Binary names' style on JNI for ClassLoader.loadClass
72+
[FIX] Android: allow cleartext HTTP traffic by default for all tests project
73+
[FIX] Windows: Support VS2017 in release mode
6674
[FIX] Action: fix repeat CallFunc for some times, may never stop
6775
[FIX] Physics: fix PhysicsJointMotor setRate and getRate Bad Access Crash
6876
[FIX] FileUtils: fix removeDirectory() failure on win32
6977
[FIX] FileUtils: let getContents return an error code when the filename is a directory
7078
[FIX] FileUtils: let isFileExistInternal return false when folder as parameter on Linux
79+
[FIX] LUA: performance drop bug introduced in 3.17
7180
[FIX] CMake: fix project name always be "TemplateCpp" when create a new project
7281
[FIX] Tests: fix auto test stop in cpp-tests project
82+
[FIX] cocos console: do uninstall only when that app is installed for android
7383

7484
cocos2d-x-3.17 May.21 2018
7585

@@ -1237,7 +1247,7 @@ cocos2d-x-3.7rc0 July.1 2015
12371247
[NEW] C++: Added ActionFloat
12381248
[NEW] C++: Supported physical keyboard on WinRT
12391249
[NEW] FileUtils: checked filename case characters on windows
1240-
[NEW] FileUitls: added supporting loading files that which file path include utf-8 characters
1250+
[NEW] FileUtils: added supporting loading files that which file path include utf-8 characters
12411251
[NEW] PhysicsShape: added sensor property
12421252
[NEW] Sprite: used triangle command
12431253
[NEW] 3d: Added `getFarPlane` and `getNearPlane` in `Camera` class

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,12 @@ set(BUILD_LUA_LIBS ON)
4646
set(BUILD_JS_LIBS ON)
4747

4848
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
49-
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests ${ENGINE_BINARY_PATH}/tests)
5049

50+
# prevent tests project to build "cocos2d-x/cocos" again
51+
set(BUILD_ENGINE_DONE ON)
52+
# add engine all tests project
53+
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/cpp-empty-test ${ENGINE_BINARY_PATH}/tests/cpp-empty-test)
54+
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/cpp-tests ${ENGINE_BINARY_PATH}/tests/cpp-tests)
55+
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/js-tests/project ${ENGINE_BINARY_PATH}/tests/js-tests)
56+
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/lua-empty-test/project ${ENGINE_BINARY_PATH}/tests/lua-empty-test)
57+
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/lua-tests/project ${ENGINE_BINARY_PATH}/tests/lua-test)

cmake/Modules/CocosBuildHelpers.cmake

+26-30
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
include(CMakeParseArguments)
22

3-
# copy resource `FILES` and `FOLDERS` to `COPY_TO` folder
4-
function(cocos_copy_res)
3+
# copy resource `FILES` and `FOLDERS` to TARGET_FILE_DIR/Resources
4+
function(cocos_copy_target_res cocos_target)
55
set(oneValueArgs COPY_TO)
66
set(multiValueArgs FILES FOLDERS)
77
cmake_parse_arguments(opt "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
88
# copy files
99
foreach(cc_file ${opt_FILES})
1010
get_filename_component(file_name ${cc_file} NAME)
11-
configure_file(${cc_file} "${opt_COPY_TO}/${file_name}" COPYONLY)
11+
add_custom_command(TARGET ${cocos_target} POST_BUILD
12+
COMMAND ${CMAKE_COMMAND} -E echo "copy file into Resources: ${file_name} ..."
13+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cc_file} "${opt_COPY_TO}/${file_name}"
14+
)
1215
endforeach()
1316
# copy folders files
1417
foreach(cc_folder ${opt_FOLDERS})
@@ -17,7 +20,10 @@ function(cocos_copy_res)
1720
foreach(res_file ${folder_files})
1821
get_filename_component(res_file_abs_path ${res_file} ABSOLUTE)
1922
file(RELATIVE_PATH res_file_relat_path ${folder_abs_path} ${res_file_abs_path})
20-
configure_file(${res_file} "${opt_COPY_TO}/${res_file_relat_path}" COPYONLY)
23+
add_custom_command(TARGET ${cocos_target} POST_BUILD
24+
COMMAND ${CMAKE_COMMAND} -E echo "copy file into Resources: ${res_file_relat_path} ..."
25+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${res_file} "${opt_COPY_TO}/${res_file_relat_path}"
26+
)
2127
endforeach()
2228
endforeach()
2329
endfunction()
@@ -79,8 +85,9 @@ function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out)
7985
search_depend_libs_recursive(${cocos_target} depend_libs)
8086
foreach(depend_lib ${depend_libs})
8187
if(TARGET ${depend_lib})
82-
get_target_property(tmp_dlls ${depend_lib} CC_DEPEND_DLLS)
83-
if(tmp_dlls)
88+
get_target_property(found_shared_lib ${depend_lib} IMPORTED_IMPLIB)
89+
if(found_shared_lib)
90+
get_target_property(tmp_dlls ${depend_lib} IMPORTED_LOCATION)
8491
list(APPEND all_depend_ext_dlls ${tmp_dlls})
8592
endif()
8693
endif()
@@ -89,20 +96,19 @@ function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out)
8996
set(${all_depend_dlls_out} ${all_depend_ext_dlls} PARENT_SCOPE)
9097
endfunction()
9198

92-
# copy the `cocos_target` needed dlls into `COPY_TO` folder
99+
# copy the `cocos_target` needed dlls into TARGET_FILE_DIR
93100
function(cocos_copy_target_dll cocos_target)
94-
set(oneValueArgs COPY_TO)
95-
cmake_parse_arguments(opt "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
96101
get_target_depends_ext_dlls(${cocos_target} all_depend_dlls)
97102
# remove repeat items
98103
if(all_depend_dlls)
99104
list(REMOVE_DUPLICATES all_depend_dlls)
100105
endif()
101-
# todo, add a option to enable/disable debug print
102-
message(STATUS "prepare to copy external dlls for ${cocos_target}:${all_depend_dlls}")
103106
foreach(cc_dll_file ${all_depend_dlls})
104107
get_filename_component(cc_dll_name ${cc_dll_file} NAME)
105-
configure_file(${cc_dll_file} "${opt_COPY_TO}/${cc_dll_name}" COPYONLY)
108+
add_custom_command(TARGET ${cocos_target} POST_BUILD
109+
COMMAND ${CMAKE_COMMAND} -E echo "copy dll into target file dir: ${cc_dll_name} ..."
110+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cc_dll_file} "$<TARGET_FILE_DIR:${cocos_target}>/${cc_dll_name}"
111+
)
106112
endforeach()
107113
endfunction()
108114

@@ -168,31 +174,21 @@ function(source_group_single_file single_file)
168174
source_group("${ide_file_group}" FILES ${single_file})
169175
endfunction()
170176

171-
# setup a cocos application, include "APP_BIN_DIR", "APP_RES_DIR" config
177+
# setup a cocos application
172178
function(setup_cocos_app_config app_name)
173-
# set target PROPERTIES, depend different platforms
179+
# put all output app into bin/${app_name}
180+
set_target_properties(${app_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${app_name}")
174181
if(APPLE)
175-
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
176-
set_target_properties(${app_name} PROPERTIES MACOSX_BUNDLE 1
177-
)
182+
# output macOS/iOS .app
183+
set_target_properties(${app_name} PROPERTIES MACOSX_BUNDLE 1)
178184
elseif(MSVC)
179-
# only Debug and Release mode was supported when using MSVC.
180-
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}/$<CONFIG>")
181-
set(APP_RES_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}/${CMAKE_BUILD_TYPE}/Resources")
182-
#Visual Studio Defaults to wrong type
183-
set_target_properties(${app_name} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
184-
else(LINUX)
185-
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/${APP_NAME}")
186-
set(APP_RES_DIR "${APP_BIN_DIR}/Resources")
185+
# visual studio default is Console app, but we need Windows app
186+
set_property(TARGET ${app_name} APPEND PROPERTY LINK_FLAGS "/SUBSYSTEM:WINDOWS")
187187
endif()
188-
set_target_properties(${app_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
189-
190188
# auto mark code files for IDE when mark app
191189
if(XCODE OR VS)
192-
cocos_mark_code_files(${APP_NAME})
190+
cocos_mark_code_files(${app_name})
193191
endif()
194-
195-
set(APP_RES_DIR ${APP_RES_DIR} PARENT_SCOPE)
196192
endfunction()
197193

198194
# if cc_variable not set, then set it cc_value

cmake/Modules/CocosConfigDefine.cmake

+23-29
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,35 @@
2525
set(MACOSX TRUE)
2626
set(PLATFORM_FOLDER mac)
2727
endif()
28-
else()
28+
else()
2929
message(FATAL_ERROR "Unsupported platform, CMake will exit")
3030
return()
3131
endif()
3232

33-
# build mode, Debug is default value
34-
if(NOT CMAKE_BUILD_TYPE)
35-
if(DEBUG_MODE)
36-
set(CMAKE_BUILD_TYPE Debug)
37-
else()
38-
set(CMAKE_BUILD_TYPE Release)
39-
endif()
40-
endif()
33+
# generators that are capable of organizing into a hierarchy of folders
34+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
35+
# simplify generator condition, please use them everywhere
36+
if(CMAKE_GENERATOR STREQUAL Xcode)
37+
set(XCODE TRUE)
38+
elseif(CMAKE_GENERATOR MATCHES Visual)
39+
set(VS TRUE)
40+
endif()
41+
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
4142

42-
if(CMAKE_GENERATOR)
43-
# generators that are capable of organizing into a hierarchy of folders
44-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
45-
# simplify generator condition judgement
46-
if(CMAKE_GENERATOR STREQUAL Xcode)
47-
set(XCODE TRUE)
48-
elseif(CMAKE_GENERATOR MATCHES Visual)
49-
set(VS TRUE)
43+
if(CMAKE_CONFIGURATION_TYPES)
44+
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Reset the configurations to what we need" FORCE)
45+
message(STATUS "CMAKE_CONFIGURATION_TYPES: ${CMAKE_CONFIGURATION_TYPES}")
46+
else()
47+
if(NOT CMAKE_BUILD_TYPE)
48+
if(DEBUG_MODE) # build mode, Debug is default value
49+
set(CMAKE_BUILD_TYPE Debug)
50+
else()
51+
set(CMAKE_BUILD_TYPE Release)
52+
endif()
5053
endif()
51-
# make configurations type keep same to cmake build type.
52-
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE STRING "Reset the configurations to what we need" FORCE)
53-
endif()
54-
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
55-
54+
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
55+
endif()
5656

57-
# custom target property for dll collect
58-
define_property(TARGET
59-
PROPERTY CC_DEPEND_DLLS
60-
BRIEF_DOCS "depend dlls of a target"
61-
FULL_DOCS "use to save depend dlls of a target"
62-
)
6357
# custom target property for lua/js link
6458
define_property(TARGET
6559
PROPERTY CC_JS_DEPEND
@@ -96,7 +90,7 @@ endif()
9690

9791
# Set macro definitions for special platforms
9892
function(use_cocos2dx_compile_define target)
99-
target_compile_definitions(${target} PUBLIC "COCOS2D_DEBUG$<$<CONFIG:Debug>:=1>")
93+
target_compile_definitions(${target} PUBLIC $<$<CONFIG:Debug>:COCOS2D_DEBUG=1>)
10094
if(APPLE)
10195
target_compile_definitions(${target} PUBLIC __APPLE__)
10296
target_compile_definitions(${target} PUBLIC USE_FILE32API)

cmake/Modules/iOSBundleInfo.plist.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
<string>LaunchScreen</string>
3939
<key>UISupportedInterfaceOrientations</key>
4040
<array>
41-
<string>UIInterfaceOrientationLandscapeLeft</string>
4241
<string>UIInterfaceOrientationLandscapeRight</string>
42+
<string>UIInterfaceOrientationLandscapeLeft</string>
4343
</array>
4444
<key>NSHumanReadableCopyright</key>
4545
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>

cmake/README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CMake is an open-source, cross-platform family of tools designed to build, test
88
```sh
99
cmake --version
1010
```
11-
if the CMake version is lower than 3.1, please upgrade.
11+
if the CMake version is lower than 3.6, please upgrade.
1212

1313
2. You should use __out-of-source__ builds, this means you need to create a different directory than __cocos2d-x__ to execute the `cmake` command.
1414

@@ -33,7 +33,14 @@ mkdir win32-build && cd win32-build
3333
cmake .. -G"Visual Studio 15 2017" -Tv141
3434
```
3535

36-
Execute `cmake --build .` to compile, or open __Cocos2d-x.sln__ in Explorer to use the generated project.
36+
Execute `cmake --build .` to compile,
37+
```
38+
cmake --build . --config Debug
39+
cmake --build . --config Release
40+
```
41+
or open __Cocos2d-x.sln__ in Explorer to use the generated project.
42+
43+
If can't found `MSVCR110.dll` issue occurs to you, please install this [Visual C++ Runtime Libraries](https://www.microsoft.com/en-us/download/details.aspx?id=30679), when runing the cpp-tests project
3744

3845
### Generate macOS Project
3946

@@ -53,7 +60,9 @@ cmake .. -GXcode -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake
5360
open Cocos2d-x.xcodeproj
5461
```
5562

56-
The default build is for running on actual iOS hardware, if you want to run in the simulator, please add `-DIOS_PLATFORM=SIMULATOR` for architecture i386 or `-DIOS_PLATFORM=SIMULATOR64` for x86_64.
63+
The default build is for running on iOS device, if you want to run in the simulator, please add `-DIOS_PLATFORM=SIMULATOR` for architecture i386 or `-DIOS_PLATFORM=SIMULATOR64` for x86_64, but remember you can't run metal-support app in simulator because Apple limitation.
64+
65+
if you want to sign iOS app in CMake, you will need to fill development team ID into `set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")`, or select to sign in Xcode after project files generated.
5766

5867
### Android Studio
5968

@@ -91,6 +100,11 @@ If you want to add cmake build arguments, please add it at [external Native Buil
91100

92101
* `cmake --build ./msvc_build`, cmake will sellect corresponding build tools.
93102

103+
## Tips
104+
105+
1. Use `cmake ..` to refersh resources and code files, after you modify `Resources` or `CMakeLists.txt`.
106+
1. Don't need `CMAKE_BUILD_TYPE` options when `-G` Xcode or Visual Studio, CMake scripts will generate both configurations, so you can switch `Debug` and `Release` in IDE.
107+
94108
## Useful Links
95109

96110
* CMake Official website: [cmake.org](https://cmake.org/)

cmake/ios.toolchain.cmake

+13-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ set(UNIX True)
3535
set(APPLE True)
3636
set(IOS True)
3737

38-
# Required as of cmake 2.8.10
39-
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
38+
# support iOS on cmake 3.11+
39+
# cmake 3.11 milestone feature, https://gitlab.kitware.com/cmake/cmake/issues/17431
40+
set(CMAKE_OSX_DEPLOYMENT_TARGET "8.0" CACHE STRING "set of the deployment target for iOS" FORCE)
4041

4142
# Determine the cmake host system version so we know where to find the iOS SDKs
4243
find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
@@ -203,4 +204,13 @@ macro(find_host_package)
203204
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
204205
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
205206
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
206-
endmacro(find_host_package)
207+
endmacro(find_host_package)
208+
209+
# This macro lets you find library on the host system
210+
macro(find_host_library)
211+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
212+
213+
find_library(${ARGN})
214+
215+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
216+
endmacro(find_host_library)

cocos/2d/CCSpriteFrameCache.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist)
377377
{
378378
CCASSERT(!plist.empty(), "plist filename should not be nullptr");
379379

380+
if (_spriteFramesCache.isPlistFull(plist))
381+
{
382+
return;
383+
}
384+
380385
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
381386
if (fullPath.empty())
382387
{

cocos/2d/libcocos2d.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\OpenalSoft\prebuilt\*.*"
113113
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\MP3Decoder\prebuilt\*.*" "$(OutDir)"
114114
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\OggDecoder\prebuilt\*.*" "$(OutDir)"
115115
xcopy /Y /Q "$(ProjectDir)..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)"
116-
xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*" "$(OutDir)"
116+
xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\debug-lib\*.*" "$(OutDir)"
117117
xcopy /Y /Q "$(ProjectDir)..\..\external\bullet\prebuilt\win32\debug\*.*" "$(OutDir)"
118118
xcopy /Y /Q "$(ProjectDir)..\..\external\Box2D\prebuilt\win32\debug\*.*" "$(OutDir)"
119119
xcopy /Y /Q "$(ProjectDir)..\..\external\openssl\prebuilt\win32\*.*" "$(OutDir)"

cocos/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,12 @@ endif()
161161
if(XCODE OR VS)
162162
cocos_mark_code_files("cocos2d")
163163
endif()
164+
165+
if(WINDOWS)
166+
# precompiled header. Compilation time speedup ~4x.
167+
target_sources(cocos2d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
168+
set_target_properties(cocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
169+
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
170+
# compile c as c++. needed for precompiled header
171+
set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX)
172+
endif()

0 commit comments

Comments
 (0)