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/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() diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 0d8d27a121b6..e5883ccff64c 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -483,3 +483,10 @@ endif() if(LINUX OR WINDOWS) cocos_copy_res(COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER}) 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