summaryrefslogtreecommitdiffstats
path: root/cmake/CCacheDebugInfoWorkaround.cmake
blob: 743b9b8ea89ca044005331e0b99383c177e8d333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Make sure that shared debug info doesn't intefere with caching
# See the sccache readme
if(
    MSVC
    AND (NOT DEFINED CMAKE_MSVC_DEBUG_INFORMATION_FORMAT)
    AND (
        CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache"
        OR CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache"
    )
)
    message(
        NOTICE
        "Setting embedded debug info for MSVC to work around (s)ccache's inability to cache shared debug info files"
    )
    cmake_minimum_required(VERSION 3.25)
    cmake_policy(GET CMP0141 cmp0141)
    if(NOT cmp0141 STREQUAL "NEW")
        message(WARNING "Need CMake policy 0141 enabled")
    endif()
    set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
        "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>"
    )
endif()