diff options
author | Eike Ziller <eike.ziller@qt.io> | 2021-04-23 10:38:22 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2021-04-26 07:01:51 +0000 |
commit | 79afbe7f148d62dd41283c2fbfbd058371197830 (patch) | |
tree | af823afe9df63dc988e3ec62ca48a39c89996fd4 /cmake | |
parent | 1effc866422b216632c65b43e373b56d0c247b80 (diff) |
COIN: Add hack to support debug info with sccache and MSVC
sccache does not support the "/Zi /FS" option for debug information
with MSVC. Optionally replace "/Zi" by "/Z7", which leaves debug
information in the object files and only collects it at link time.
See also qtbase 2354274f39934b94383923834479901106489def.
Change-Id: Id94c2116f3c4192556dbdf8fe82b12ce0a204273
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtCreatorAPI.cmake | 1 | ||||
-rw-r--r-- | cmake/QtCreatorAPIInternal.cmake | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 921106a3f6..756b0befa2 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -40,6 +40,7 @@ option(BUILD_PLUGINS_BY_DEFAULT "Build plugins by default. This can be used to b option(BUILD_EXECUTABLES_BY_DEFAULT "Build executables by default. This can be used to build all executables by default, or none." ON) option(BUILD_LIBRARIES_BY_DEFAULT "Build libraries by default. This can be used to build all libraries by default, or none." ON) option(QTC_SEPARATE_DEBUG_INFO "Extract debug information from binary files." OFF) +option(WITH_SCCACHE_SUPPORT "Enables support for building with SCCACHE and separate debug info with MSVC, which SCCACHE normally doesn't support." OFF) # If we provide a list of plugins, executables, libraries, then the BUILD_<type>_BY_DEFAULT will be set to OFF # and for every element we set BUILD_<type>_<elment> to ON diff --git a/cmake/QtCreatorAPIInternal.cmake b/cmake/QtCreatorAPIInternal.cmake index 8335ae3457..549f05a944 100644 --- a/cmake/QtCreatorAPIInternal.cmake +++ b/cmake/QtCreatorAPIInternal.cmake @@ -103,6 +103,25 @@ set(__QTC_LIBRARIES "" CACHE INTERNAL "*** Internal ***") set(__QTC_EXECUTABLES "" CACHE INTERNAL "*** Internal ***") set(__QTC_TESTS "" CACHE INTERNAL "*** Internal ***") +# handle SCCACHE hack +# SCCACHE does not work with the /Zi option, which makes each compilation write debug info +# into the same .pdb file - even with /FS, which usually makes this work in the first place. +# Replace /Zi with /Z7, which leaves the debug info in the object files until link time. +# This increases memory usage, disk space usage and linking time, so should only be +# enabled if necessary. +# Must be called after project(...). +function(qtc_handle_sccache_support) + if (MSVC AND WITH_SCCACHE_SUPPORT) + foreach(config DEBUG RELWITHDEBINFO) + foreach(lang C CXX) + set(flags_var "CMAKE_${lang}_FLAGS_${config}") + string(REPLACE "/Zi" "/Z7" ${flags_var} "${${flags_var}}") + set(${flags_var} "${${flags_var}}" PARENT_SCOPE) + endforeach() + endforeach() + endif() +endfunction() + function(append_extra_translations target_name) if(NOT ARGN) return() |