From 657af6be365a269d90393f42548b0e6ddcc06c2e Mon Sep 17 00:00:00 2001 From: mariusz Date: Sun, 30 Dec 2018 18:51:06 +0100 Subject: [PATCH 1/4] Precompiled header --- tests/cpp-tests/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 0d8d27a121b6..e3f9a15132d7 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -483,3 +483,8 @@ endif() if(LINUX OR WINDOWS) cocos_copy_res(COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER}) endif() + +if(WIN32) + set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h") + set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h") +endif() \ No newline at end of file From 63b3503a5ff35203bce69ef68597869326e8889f Mon Sep 17 00:00:00 2001 From: mariusz Date: Sun, 30 Dec 2018 21:42:01 +0100 Subject: [PATCH 2/4] Fix --- tests/cpp-tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index e3f9a15132d7..b70501dc58b0 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -332,6 +332,7 @@ list(APPEND GAME_SOURCE Classes/controller.cpp # Classes/VRTest/VRTest.cpp # Classes/VRTest/VRTest.h + Classes/precheader.cpp ) if(ANDROID OR IOS) From e2fd7b13214f1e3b5bac17b62f925e37a83893ee Mon Sep 17 00:00:00 2001 From: mariusz Date: Mon, 31 Dec 2018 11:32:35 +0100 Subject: [PATCH 3/4] Precompiled header for cocos --- cocos/CMakeLists.txt | 9 +++++++++ tests/cpp-tests/CMakeLists.txt | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index c899d6a6b722..f3e80ff884f6 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -161,3 +161,12 @@ endif() if(XCODE OR VS) cocos_mark_code_files("cocos2d") endif() + +if(WIN32) + # precompiled header. Compilation time speedup ~4x. + target_sources(cocos2d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp") + set_target_properties(cocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h") + set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h") + # compile c as c++. needed for precompiled header + set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX) +endif() diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index b70501dc58b0..e5883ccff64c 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -332,7 +332,6 @@ list(APPEND GAME_SOURCE Classes/controller.cpp # Classes/VRTest/VRTest.cpp # Classes/VRTest/VRTest.h - Classes/precheader.cpp ) if(ANDROID OR IOS) @@ -486,6 +485,8 @@ if(LINUX OR WINDOWS) endif() if(WIN32) + # precompiled header. Compilation time speedup ~4x. + target_sources(${APP_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp") set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h") set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h") endif() \ No newline at end of file From 114e19503319409be4477dbb9d46ff5389ef89c6 Mon Sep 17 00:00:00 2001 From: mariusz Date: Mon, 31 Dec 2018 11:46:28 +0100 Subject: [PATCH 4/4] Precompiled header jscocos2d --- cocos/scripting/js-bindings/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/CMakeLists.txt b/cocos/scripting/js-bindings/CMakeLists.txt index e609264be4ff..204e59a3b8fa 100644 --- a/cocos/scripting/js-bindings/CMakeLists.txt +++ b/cocos/scripting/js-bindings/CMakeLists.txt @@ -178,4 +178,11 @@ set_target_properties(jscocos2d if(XCODE OR VS) cocos_mark_code_files("jscocos2d") -endif() \ No newline at end of file +endif() + +if(WIN32) + # precompiled header + target_sources(jscocos2d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp") + set_target_properties(jscocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h") + set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h") +endif()