Skip to content

Commit 88ea544

Browse files
crazyhappygamehuangwei1024
authored andcommitted
cmake win32 Precompiled header (cocos2d#19273)
* Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d
1 parent b706d9e commit 88ea544

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

cocos/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
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(WIN32)
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()

cocos/scripting/js-bindings/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,11 @@ set_target_properties(jscocos2d
178178

179179
if(XCODE OR VS)
180180
cocos_mark_code_files("jscocos2d")
181-
endif()
181+
endif()
182+
183+
if(WIN32)
184+
# precompiled header
185+
target_sources(jscocos2d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
186+
set_target_properties(jscocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
187+
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
188+
endif()

tests/cpp-tests/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,10 @@ endif()
483483
if(LINUX OR WINDOWS)
484484
cocos_copy_res(COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
485485
endif()
486+
487+
if(WIN32)
488+
# precompiled header. Compilation time speedup ~4x.
489+
target_sources(${APP_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp")
490+
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
491+
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
492+
endif()

0 commit comments

Comments
 (0)