From 39b3a95efb28838fcdd3071f18919a8a3a7e1047 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Tue, 4 Jul 2023 17:38:02 +0200 Subject: [PATCH] CMake: Enable CMAKE_OPTIMIZE_DEPENDENCIES by default Ever since #107858 landed builds of a single library from a clean state were significant heavier than they used to the since the full dependency chain is being build. While this is desired behavior since some projects emit artefacts (like bf_dna's dna_type_offsets.h) for others given we are building static libraries that don't actually get linked until the very end this is unneeded. CMake offers a flag here to optimize this called CMAKE_OPTIMIZE_DEPENDENCIES. See the CMake docs for details what this exactly does. This diff changes the default for CMAKE_OPTIMIZE_DEPENDENCIES from Off to On for all CMake versions that support it. If people desire to do so, this flag can still be changed though CMakeCache.txt Pull Request: https://projects.blender.org/blender/blender/pulls/109672 --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 281028d11ec..9114eb21447 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,13 @@ if(WIN32) ) endif() + +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19") + # This changes the default value from Off to On, but will still allow people to manually change + # this setting through their CMakeCache.txt if they desire to do so. + set(CMAKE_OPTIMIZE_DEPENDENCIES ON CACHE INTERNAL "") +endif() + # ----------------------------------------------------------------------------- # Declare Options