Skip to content

Commit 1c317d3

Browse files
crazyhappygamedrelaptop
authored andcommitted
cmake win32 Precompiled header (cocos2d#19273)
* Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d
1 parent 880cf4c commit 1c317d3

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
@@ -144,3 +144,12 @@ endif()
144144
if(XCODE OR VS)
145145
cocos_mark_code_files("cocos2d")
146146
endif()
147+
148+
if(WIN32)
149+
# precompiled header. Compilation time speedup ~4x.
150+
target_sources(cocos2d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
151+
set_target_properties(cocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
152+
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
153+
# compile c as c++. needed for precompiled header
154+
set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX)
155+
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
@@ -481,3 +481,10 @@ endif()
481481
if(LINUX OR WINDOWS)
482482
cocos_copy_res(COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
483483
endif()
484+
485+
if(WIN32)
486+
# precompiled header. Compilation time speedup ~4x.
487+
target_sources(${APP_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp")
488+
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
489+
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
490+
endif()

0 commit comments

Comments
 (0)