[krita] /: Make Windows build create thin archives when linking
Alvin Wong
null at kde.org
Thu Apr 4 16:35:29 BST 2019
Git commit f3858d112d54109596b28d29fd8a7bdaadfc2603 by Alvin Wong.
Committed on 04/04/2019 at 15:29.
Pushed by alvinwong into branch 'master'.
Make Windows build create thin archives when linking
This makes the Windows build create thin archives when linking the
binaries to reduce the amount of redundant writes to disk when building.
With a normal clean build, the size of the build directory has reduced
by 2GB.
When I tested building on a RAM-based filesystem, the clean build time
is reduced from 52 minutes to 50. The result could be more significant
on SSD/HDD.
(Above data does not include building the deps.)
Note: If you encountered build errors, you may need to do a clean
rebuild. This is only for Windows.
CCMAIL: kimageshop at kde.org
M +12 -0 CMakeLists.txt
https://commits.kde.org/krita/f3858d112d54109596b28d29fd8a7bdaadfc2603
diff --git a/CMakeLists.txt b/CMakeLists.txt
index db90794a4a9..c3d45d3bd9f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -446,6 +446,18 @@ if(MINGW)
string(REPLACE "-Wl,--export-all-symbols" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif(MINGW)
+if(MINGW)
+ # Hack CMake's variables to tell AR to create thin archives to reduce unnecessary writes.
+ # Source of definition: https://github.com/Kitware/CMake/blob/v3.14.1/Modules/Platform/Windows-GNU.cmake#L128
+ # Thin archives: https://sourceware.org/binutils/docs/binutils/ar.html#index-thin-archives
+ macro(mingw_use_thin_archive lang)
+ foreach(rule CREATE_SHARED_MODULE CREATE_SHARED_LIBRARY LINK_EXECUTABLE)
+ string(REGEX REPLACE "(<CMAKE_AR> [^ T]+) " "\\1T " CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}")
+ endforeach()
+ endmacro()
+ mingw_use_thin_archive(CXX)
+endif(MINGW)
+
# enable exceptions globally
kde_enable_exceptions()
More information about the kimageshop
mailing list