cmake: honor custom CMAKE_UNITY_BUILD_BATCH_SIZE

This value tells how many sources files to bundle in a single "unity"
compilation unit.

The CMake default is 8 sources, curl's CMake set this to 0, meaning
to bundle all sources into a single unit.

This patch makes it possible to override the 0 value, and potentially
optimize the build process further by better utilizing multiple cores
in conjunction with `make -jN`.

The number of sources in lib is 172 at the time of writing this. For
a 12-core CPU, this can give a job for them all:
`-DCMAKE_UNITY_BUILD_BATCH_SIZE=15`

(Compile time may be affected by a bunch of other factors.)

Closes #14626
This commit is contained in:
Viktor Szakats 2024-08-21 09:27:18 +02:00
parent 9fff0742b6
commit a62e3be67d
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -112,7 +112,9 @@ endif()
include_directories("${CURL_SOURCE_DIR}/include") include_directories("${CURL_SOURCE_DIR}/include")
if(NOT DEFINED CMAKE_UNITY_BUILD_BATCH_SIZE)
set(CMAKE_UNITY_BUILD_BATCH_SIZE 0) set(CMAKE_UNITY_BUILD_BATCH_SIZE 0)
endif()
option(CURL_WERROR "Turn compiler warnings into errors" OFF) option(CURL_WERROR "Turn compiler warnings into errors" OFF)
option(PICKY_COMPILER "Enable picky compiler options" ON) option(PICKY_COMPILER "Enable picky compiler options" ON)