summaryrefslogtreecommitdiff
path: root/cmake/CCacheDebugInfoWorkaround.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/CCacheDebugInfoWorkaround.cmake')
-rw-r--r--cmake/CCacheDebugInfoWorkaround.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/CCacheDebugInfoWorkaround.cmake b/cmake/CCacheDebugInfoWorkaround.cmake
new file mode 100644
index 000000000..82fb299e3
--- /dev/null
+++ b/cmake/CCacheDebugInfoWorkaround.cmake
@@ -0,0 +1,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, Note that this requires CMake 3.25 or greater"
+ )
+ 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()