diff options
Diffstat (limited to 'build_files')
-rw-r--r-- | build_files/cmake/macros.cmake | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index d1894ad8f24..d7716913cf5 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -1222,9 +1222,24 @@ macro(WINDOWS_SIGN_TARGET target) endmacro() macro(blender_precompile_headers target cpp header) - if (MSVC AND NOT ${CMAKE_GENERATOR} STREQUAL "Ninja") + if (MSVC) + # get the name for the pch output file + get_filename_component( pchbase ${cpp} NAME_WE ) + set( pchfinal "${CMAKE_CURRENT_BINARY_DIR}/${pchbase}.pch" ) + + # mark the cpp as the one outputting the pch + set_property(SOURCE ${cpp} APPEND PROPERTY OBJECT_OUTPUTS "${pchfinal}") + + # get all sources for the target + get_target_property(sources ${target} SOURCES) + + # make all sources depend on the pch to enforce the build order + foreach(src ${sources}) + set_property(SOURCE ${src} APPEND PROPERTY OBJECT_DEPENDS "${pchfinal}") + endforeach() + target_sources(${target} PRIVATE ${cpp} ${header}) - set_target_properties(${target} PROPERTIES COMPILE_FLAGS "/Yu${header} /FI${header}") - set_source_files_properties(${cpp} PROPERTIES COMPILE_FLAGS "/Yc${header}") + set_target_properties(${target} PROPERTIES COMPILE_FLAGS "/Yu${header} /Fp${pchfinal} /FI${header}") + set_source_files_properties(${cpp} PROPERTIES COMPILE_FLAGS "/Yc${header} /Fp${pchfinal}") endif() endmacro() |