Commit f3858d11 authored by Alvin Wong's avatar Alvin Wong

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@kde.org
parent 2c92f588
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment