Cleanup: Improve comments
[blender.git] / build_files / cmake / platform / platform_win32_bundle_crt.cmake
1 # First generate the manifest for tests since it will not need the dependency on the CRT.
2 configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/tests.exe.manifest @ONLY)
3
4 if(WITH_WINDOWS_BUNDLE_CRT)
5   set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
6   set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
7   set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
8
9   # This sometimes can change when updates are installed and the compiler version
10   # changes, so test if it exists and if not, give InstallRequiredSystemLibraries
11   # another chance to figure out the path.
12   if(MSVC_REDIST_DIR AND NOT EXISTS "${MSVC_REDIST_DIR}")
13     unset(MSVC_REDIST_DIR CACHE)
14   endif()
15
16   include(InstallRequiredSystemLibraries)
17
18   # Install the CRT to the blender.crt Sub folder.
19   install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ./blender.crt COMPONENT Libraries)
20
21   # Generating the manifest is a relativly expensive operation since
22   # it is collecting an sha1 hash for every file required. so only do
23   # this work when the libs have either changed or the manifest does
24   # not exist yet.
25
26   string(SHA1 libshash "${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}")
27   set(manifest_trigger_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/crt_${libshash}")
28
29   if(NOT EXISTS ${manifest_trigger_file})
30     set(CRTLIBS "")
31     foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
32       get_filename_component(filename ${lib} NAME)
33       file(SHA1 "${lib}" sha1_file)
34       string(APPEND CRTLIBS "    <file name=\"${filename}\" hash=\"${sha1_file}\"  hashalg=\"SHA1\" />\n")
35     endforeach()
36     configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.crt.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/blender.crt.manifest @ONLY)
37     file(TOUCH ${manifest_trigger_file})
38   endif()
39
40   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.crt.manifest DESTINATION ./blender.crt)
41   set(BUNDLECRT "<dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"blender.crt\" version=\"1.0.0.0\" /></dependentAssembly></dependency>")
42 endif()
43 configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/blender.exe.manifest @ONLY)