Skip to content

Commit

Permalink
ci: add ccache support for uwp
Browse files Browse the repository at this point in the history
  • Loading branch information
scribam committed Jan 27, 2024
1 parent 976c2ed commit a9a4fc6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,33 @@ jobs:
build:
runs-on: windows-latest

env:
CCACHE_DIR: ${{ github.workspace }}/.ccache

steps:
- name: Set up build environment
run: choco install ccache

- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-uwp-${{ github.sha }}
restore-keys: ccache-uwp-

- name: CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.22000.0
cmake --build build --config Release --parallel 2
shell: cmd

- name: ccache -s
run: ccache -s

- uses: ilammy/msvc-dev-cmd@v1

- name: Package app
Expand Down
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@ else()
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

if(MSVC)
# Disable use of separate PDB, Ccache won't cache things otherwise
foreach(lang IN ITEMS C CXX)
foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES)
set(var CMAKE_${lang}_FLAGS)
if(NOT config STREQUAL "")
string(TOUPPER "${config}" config)
string(APPEND var "_${config}")
endif()
string(REGEX REPLACE "[-/]Z[iI]" "-Z7" ${var} "${${var}}")
set(${var} "${${var}}" PARENT_SCOPE)
endforeach()
endforeach()
if(DEFINED CMAKE_MSVC_DEBUG_INFORMATION_FORMAT)
string(REGEX REPLACE "ProgramDatabase|EditAndContinue" "Embedded"
replaced "${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}"
)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "${replaced}" PARENT_SCOPE)
else()
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
"$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>"
PARENT_SCOPE
)
endif()
endif()

include(DetectArchitecture)
if(NOT DEFINED ARCHITECTURE)
message(FATAL_ERROR "Unsupported architecture encountered. Ending CMake generation.")
Expand Down

0 comments on commit a9a4fc6

Please sign in to comment.