[Bf-blender-cvs] [050b205a97c] master: CMake: add WITH_UNITY_BUILD option to improve compile times

Jacques Lucke noreply at git.blender.org
Wed Nov 24 11:46:16 CET 2021


Commit: 050b205a97c4dc0b9819fd2eea1fbe78cc1981ec
Author: Jacques Lucke
Date:   Wed Nov 24 11:40:26 2021 +0100
Branches: master
https://developer.blender.org/rB050b205a97c4dc0b9819fd2eea1fbe78cc1981ec

CMake: add WITH_UNITY_BUILD option to improve compile times

Unity builds are only used in the `bf_nodes_geometry` module for now.
This module has been prepared to support unity builds already.
Usually, there is a 2-4x speedup when building `bf_nodes_geometry`
compared to without unity builds (e.g. 145s to 55s).

For more information about how unity builds work and how they help
with compile times, see D13341.

Differential Revision: https://developer.blender.org/D13341

===================================================================

M	CMakeLists.txt
M	source/blender/nodes/geometry/CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9c29101123..bdb798228e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,6 +187,13 @@ mark_as_advanced(CPACK_OVERRIDE_PACKAGENAME)
 mark_as_advanced(BUILDINFO_OVERRIDE_DATE)
 mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
 
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
+  option(WITH_UNITY_BUILD   "Enable unity build for modules that support it to improve compile times" ON)
+  mark_as_advanced(WITH_UNITY_BUILD)
+else()
+  set(WITH_UNITY_BUILD OFF)
+endif()
+
 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
 option(WITH_IK_SOLVER     "Enable Legacy IK solver (only disable for development)" ON)
 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON)
diff --git a/source/blender/nodes/geometry/CMakeLists.txt b/source/blender/nodes/geometry/CMakeLists.txt
index 61b5bbf6e7e..576c5249e98 100644
--- a/source/blender/nodes/geometry/CMakeLists.txt
+++ b/source/blender/nodes/geometry/CMakeLists.txt
@@ -265,3 +265,8 @@ if(WITH_OPENVDB)
 endif()
 
 blender_add_lib(bf_nodes_geometry "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+if(WITH_UNITY_BUILD)
+  set_target_properties(bf_nodes_geometry PROPERTIES UNITY_BUILD ON)
+  set_target_properties(bf_nodes_geometry PROPERTIES UNITY_BUILD_BATCH_SIZE 10)
+endif()



More information about the Bf-blender-cvs mailing list