Skip to content

Commit cd7446f

Browse files
Create pch for all platforms V3 (#20705)
1 parent 387f56a commit cd7446f

File tree

4 files changed

+31
-35
lines changed

4 files changed

+31
-35
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ jobs:
2121
- run: cmake -B b -S .
2222
- run: cmake --build b
2323

24-
ubuntu-20_04:
25-
runs-on: ubuntu-20.04
26-
steps:
27-
- uses: actions/checkout@v2
28-
- run: python download-deps.py --r no
29-
- run: echo -e "y" | bash build/install-deps-linux.sh
30-
- run: cmake -B b -S .
31-
- run: cmake --build b
24+
# https://github.com/cocos2d/cocos2d-x/issues/20471
25+
# ubuntu-20_04:
26+
# runs-on: ubuntu-20.04
27+
# steps:
28+
# - uses: actions/checkout@v2
29+
# - run: python download-deps.py --r no
30+
# - run: echo -e "y" | bash build/install-deps-linux.sh
31+
# - run: cmake -B b -S .
32+
# - run: cmake --build b
3233

3334
windows-2019:
3435
runs-on: windows-2019
@@ -51,34 +52,34 @@ jobs:
5152
steps:
5253
- uses: actions/checkout@v2
5354
- run: python download-deps.py --r no
54-
- run: cmake -B b -S .
55-
- run: cmake --build b
55+
- run: cmake -B b -S . -GXcode
56+
- run: cmake --build b --target cpp-tests
5657

5758
macos-11:
5859
runs-on: macos-11
5960
steps:
6061
- uses: actions/checkout@v2
6162
- run: python download-deps.py --r no
62-
- run: cmake -B b -S .
63-
- run: cmake --build b
63+
- run: cmake -B b -S . -GXcode
64+
- run: cmake --build b --target cpp-tests
6465

65-
macos-10_15_ios:
66+
ios_macos-10_15:
6667
runs-on: macos-10.15
6768
steps:
6869
- uses: actions/checkout@v2
6970
- run: python download-deps.py --r no
70-
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
71+
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_SYSTEM_PROCESSOR=arm64
7172
- run: cmake --build b --config Release --target cpp-tests -- -quiet
7273

73-
macos-11_ios:
74+
ios_macos-11:
7475
runs-on: macos-11
7576
steps:
7677
- uses: actions/checkout@v2
7778
- run: python download-deps.py --r no
78-
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
79+
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_SYSTEM_PROCESSOR=arm64
7980
- run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"
8081

81-
windows-2019-android:
82+
android_windows-2019:
8283
runs-on: windows-2019
8384
steps:
8485
- uses: actions/checkout@v2
@@ -87,7 +88,7 @@ jobs:
8788
shell: bash
8889
working-directory: tests/cpp-tests/proj.android
8990

90-
ubuntu-20_04-android:
91+
android_ubuntu-20_04:
9192
runs-on: ubuntu-20.04
9293
steps:
9394
- uses: actions/checkout@v2

cocos/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ if(XCODE OR VS)
162162
cocos_mark_code_files("cocos2d")
163163
endif()
164164

165-
if(WINDOWS)
166-
# precompiled header. Compilation time speedup ~4x.
167-
target_sources(cocos2d PRIVATE "${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)
165+
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
166+
message("CMake 3.16 target_precompile_headers")
167+
target_precompile_headers(cocos2d PRIVATE
168+
"$<$<COMPILE_LANGUAGE:CXX>:cocos2d.h>")
172169
endif()

cocos/scripting/js-bindings/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ if(XCODE OR VS)
180180
cocos_mark_code_files("jscocos2d")
181181
endif()
182182

183-
if(WINDOWS)
184-
# precompiled header
185-
target_sources(jscocos2d PRIVATE "${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")
183+
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
184+
message("CMake 3.16 target_precompile_headers")
185+
target_precompile_headers(jscocos2d PRIVATE
186+
"$<$<COMPILE_LANGUAGE:CXX>:precheader.h>")
188187
endif()

tests/cpp-tests/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,8 @@ if(LINUX OR WINDOWS)
486486
cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
487487
endif()
488488

489-
if(WINDOWS)
490-
# precompiled header. Compilation time speedup ~4x.
491-
target_sources(${APP_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp")
492-
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
493-
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
489+
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
490+
message("CMake 3.16 target_precompile_headers")
491+
target_precompile_headers(${APP_NAME} PRIVATE
492+
"$<$<COMPILE_LANGUAGE:CXX>:precheader.h>")
494493
endif()

0 commit comments

Comments
 (0)