diff --git a/CMakeLists.txt b/CMakeLists.txt index 58034fb97de..d57c7495547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -302,6 +302,12 @@ Use pre-compiled headers to speed up compilation." endif() endif() +option(WITH_OPTIMIZED_BUILD_TOOLS "\ +Enable optimizations even on Debug builds for executables used for the build process" + ON +) +mark_as_advanced(WITH_OPTIMIZED_BUILD_TOOLS) + option(WITH_IK_ITASC "\ Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON @@ -2757,6 +2763,7 @@ if(FIRST_RUN) info_cfg_text("Compiler Options:") info_cfg_option(WITH_BUILDINFO) + info_cfg_option(WITH_OPTIMIZED_BUILD_TOOLS) info_cfg_text("System Options:") info_cfg_option(WITH_INSTALL_PORTABLE) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 64270ee94e3..75d680c0cd7 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -1513,3 +1513,15 @@ function(compile_sources_as_cpp target_include_directories(${executable} PUBLIC ${INC_GLSL}) target_compile_definitions(${executable} PRIVATE ${define}) endfunction() + +macro(optimize_debug_target executable) + if(WITH_OPTIMIZED_BUILD_TOOLS) + if(WIN32) + remove_cc_flag(${executable} "/Od" "/RTC1") + target_compile_options(${executable} PRIVATE "/Ox") + target_compile_definitions(${executable} PRIVATE "_ITERATOR_DEBUG_LEVEL=0") + else() + target_compile_options(${executable} PRIVATE "-O2") + endif() + endif() +endmacro() diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 951643540fe..cc678f0a90a 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -309,6 +309,7 @@ foreach(GLSL_FILE ${GLSL_SRC}) endforeach() blender_add_lib(bf_compositor_shaders "${GLSL_C}" "" "" "") +blender_set_target_unity_build(bf_compositor_shaders 10) list(APPEND LIB bf_compositor_shaders diff --git a/source/blender/datatoc/CMakeLists.txt b/source/blender/datatoc/CMakeLists.txt index 689b3b93e37..4e7017ae7d4 100644 --- a/source/blender/datatoc/CMakeLists.txt +++ b/source/blender/datatoc/CMakeLists.txt @@ -11,3 +11,4 @@ set(SRC # `SRC_DNA_INC` is defined in the parent directory. add_executable(datatoc ${SRC}) +optimize_debug_target(datatoc) diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index c0570c65c77..5c477a1aacb 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -733,6 +733,7 @@ foreach(GLSL_FILE ${GLSL_SRC}) endforeach() blender_add_lib(bf_draw_shaders "${GLSL_C}" "" "" "") +blender_set_target_unity_build(bf_draw_shaders 10) list(APPEND LIB PRIVATE bf::animrig diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 869392dca13..5ca4f1f6565 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -710,6 +710,7 @@ if(WITH_METAL_BACKEND) endif() blender_add_lib(bf_gpu_shaders "${SHADER_C}" "" "" "") +blender_set_target_unity_build(bf_gpu_shaders 10) list(APPEND LIB bf_gpu_shaders diff --git a/source/blender/gpu/glsl_preprocess/CMakeLists.txt b/source/blender/gpu/glsl_preprocess/CMakeLists.txt index 98d5eeeba3f..2aa31e9da92 100644 --- a/source/blender/gpu/glsl_preprocess/CMakeLists.txt +++ b/source/blender/gpu/glsl_preprocess/CMakeLists.txt @@ -17,3 +17,4 @@ endif() # `SRC_DNA_INC` is defined in the parent directory. add_executable(glsl_preprocess ${SRC}) +optimize_debug_target(glsl_preprocess)