[Bf-blender-cvs] [6df2ede3414] master: Cleanup/Windows: Separate out the MS-CRT into a subfolder

Ray Molenkamp noreply at git.blender.org
Fri Dec 6 18:12:09 CET 2019


Commit: 6df2ede3414422372ac3b0b229b401e973b98509
Author: Ray Molenkamp
Date:   Fri Dec 6 10:12:03 2019 -0700
Branches: master
https://developer.blender.org/rB6df2ede3414422372ac3b0b229b401e973b98509

Cleanup/Windows: Separate out the MS-CRT into a subfolder

In older versions the ms crt was only a few dlls, in recent versions
this jumped to over 40 leading to quite a bit of clutter in our
bin folder.

This change moves the CRT into its own folder.

For developers that generally already have the runtime globaly
available on their machine, there is a new cmake option
(WITH_WINDOWS_BUNDLE_CRT, default ON) that you can use to toggle
installing the runtime to the blender bin folder, and save some
time during the initial build, this option is off by default for
only the developer profile.

Reviewed By: brecht

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

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

M	CMakeLists.txt
M	build_files/cmake/config/blender_developer.cmake
M	build_files/cmake/platform/platform_win32.cmake
A	build_files/cmake/platform/platform_win32_bundle_crt.cmake
A	release/windows/manifest/Blender.CRT.MANIFEST.in
R098	release/windows/icons/blender.exe.manifest	release/windows/manifest/blender.exe.manifest.in
M	source/creator/CMakeLists.txt

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0af6d200c6e..372fa8fa784 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -508,6 +508,10 @@ if(WIN32)
 
   option(WINDOWS_PYTHON_DEBUG "Include the files needed for debugging python scripts with visual studio 2017+." OFF)
   mark_as_advanced(WINDOWS_PYTHON_DEBUG)
+
+  option(WITH_WINDOWS_BUNDLE_CRT "Bundle the C runtime for install free distribution." ON)
+  mark_as_advanced(WITH_WINDOWS_BUNDLE_CRT)
+
 endif()
 
 # The following only works with the Ninja generator in CMake >= 3.0.
diff --git a/build_files/cmake/config/blender_developer.cmake b/build_files/cmake/config/blender_developer.cmake
index 5209ce4ed25..29092b8c7c8 100644
--- a/build_files/cmake/config/blender_developer.cmake
+++ b/build_files/cmake/config/blender_developer.cmake
@@ -13,6 +13,9 @@ set(WITH_GTESTS                       ON  CACHE BOOL "" FORCE)
 set(WITH_LIBMV_SCHUR_SPECIALIZATIONS  OFF CACHE BOOL "" FORCE)
 set(WITH_PYTHON_SAFETY                ON  CACHE BOOL "" FORCE)
 set(WITH_DOC_MANPAGE                  OFF CACHE BOOL "" FORCE)
+if(WIN32)
+  set(WITH_WINDOWS_BUNDLE_CRT         OFF CACHE BOOL "" FORCE)
+endif()
 
 # This may have issues with C++ initialization order, needs to be tested
 # on all platforms to be sure this is safe to enable.
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 2b88c710462..9061e1fcf82 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -133,14 +133,7 @@ add_definitions(-D_ALLOW_KEYWORD_MACROS)
 
 # We want to support Vista level ABI
 add_definitions(-D_WIN32_WINNT=0x600)
-
-# Make cmake find the msvc redistributables
-set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP FALSE)
-set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
-set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
-set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
-include(InstallRequiredSystemLibraries)
-
+include(build_files/cmake/platform/platform_win32_bundle_crt.cmake)
 remove_cc_flag("/MDd" "/MD")
 
 if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
diff --git a/build_files/cmake/platform/platform_win32_bundle_crt.cmake b/build_files/cmake/platform/platform_win32_bundle_crt.cmake
new file mode 100644
index 00000000000..a4aa608b013
--- /dev/null
+++ b/build_files/cmake/platform/platform_win32_bundle_crt.cmake
@@ -0,0 +1,36 @@
+if(WITH_WINDOWS_BUNDLE_CRT)
+  set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
+  set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
+  set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
+  include(InstallRequiredSystemLibraries)
+
+  # Install the CRT to the blender.crt Sub folder.
+  install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ./blender.crt COMPONENT Libraries)
+
+  # Generating the manifest is a relativly expensive operation since
+  # it is collecting an sha1 hash for every file required. so only do
+  # this work when the libs have either changed or the manifest does
+  # not exist yet.
+
+  string(SHA1 libshash "${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}")
+  set(manifest_trigger_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/crt_${libshash}")
+
+  if(NOT EXISTS ${manifest_trigger_file})
+    set(CRTLIBS "")
+    foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
+      get_filename_component(filename ${lib} NAME)
+      file(SHA1 "${lib}" sha1_file)
+      set(CRTLIBS "${CRTLIBS}    <file name=\"${filename}\" hash=\"${sha1_file}\"  hashalg=\"SHA1\" />\n")
+    endforeach()
+    configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.crt.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/blender.crt.manifest @ONLY)
+    file(TOUCH ${manifest_trigger_file})
+  endif()
+
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.crt.manifest DESTINATION ./blender.crt)
+  set(BUNDLECRT "<dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"blender.crt\" version=\"1.0.0.0\" /></dependentAssembly></dependency>")
+endif()
+configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/blender.exe.manifest @ONLY)
+
+
+
+
diff --git a/release/windows/manifest/Blender.CRT.MANIFEST.in b/release/windows/manifest/Blender.CRT.MANIFEST.in
new file mode 100644
index 00000000000..27c4a6bce56
--- /dev/null
+++ b/release/windows/manifest/Blender.CRT.MANIFEST.in
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+    <assemblyIdentity type="win32" name="Blender.CRT" version="1.0.0.0" />
+ at CRTLIBS@</assembly>
\ No newline at end of file
diff --git a/release/windows/icons/blender.exe.manifest b/release/windows/manifest/blender.exe.manifest.in
similarity index 98%
rename from release/windows/icons/blender.exe.manifest
rename to release/windows/manifest/blender.exe.manifest.in
index ceee357ecda..e73ddf3267b 100644
--- a/release/windows/icons/blender.exe.manifest
+++ b/release/windows/manifest/blender.exe.manifest.in
@@ -33,4 +33,5 @@
         />
     </dependentAssembly>
   </dependency>  
+  @BUNDLECRT@
 </assembly>
\ No newline at end of file
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 01951fb9790..3628c6efda9 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -149,7 +149,7 @@ if(WIN32 AND NOT UNIX)
 
   list(APPEND SRC
     ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc
-    ${CMAKE_SOURCE_DIR}/release/windows/icons/blender.exe.manifest
+    ${CMAKE_BINARY_DIR}/blender.exe.manifest
   )
 endif()



More information about the Bf-blender-cvs mailing list