[Bf-blender-cvs] [6d27a2ff764] master: Windows: install shared libraries in blender.shared
Ray Molenkamp
noreply at git.blender.org
Wed Dec 7 15:28:40 CET 2022
Commit: 6d27a2ff76444971180ab885fe49745c853de8aa
Author: Ray Molenkamp
Date: Mon Dec 5 23:42:49 2022 +0100
Branches: master
https://developer.blender.org/rB6d27a2ff76444971180ab885fe49745c853de8aa
Windows: install shared libraries in blender.shared
Instead of the the same folder as the Blender executable, generate a manifest
that lets us move the libraries out of the way of users and into a separate
folder.
Ref T99618
===================================================================
M build_files/cmake/macros.cmake
M build_files/cmake/platform/platform_win32.cmake
D build_files/cmake/platform/platform_win32_bundle_crt.cmake
A release/windows/manifest/Blender.manifest.in
M source/creator/CMakeLists.txt
===================================================================
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index eadf9273e26..7064ca93e8b 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -1277,3 +1277,70 @@ macro(add_bundled_libraries library_dir)
unset(_library_dir)
endif()
endmacro()
+
+macro(windows_install_shared_manifest)
+ set(options OPTIONAL DEBUG RELEASE ALL)
+ set(oneValueArgs)
+ set(multiValueArgs FILES)
+ cmake_parse_arguments(WINDOWS_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+ # If none of the options are set assume ALL.
+ unset(WINDOWS_CONFIGURATIONS)
+ if(NOT WINDOWS_INSTALL_ALL AND
+ NOT WINDOWS_INSTALL_DEBUG AND
+ NOT WINDOWS_INSTALL_RELEASE)
+ set(WINDOWS_INSTALL_ALL TRUE)
+ endif()
+ # If all is set, turn both DEBUG and RELEASE on.
+ if(WINDOWS_INSTALL_ALL)
+ set(WINDOWS_INSTALL_DEBUG TRUE)
+ set(WINDOWS_INSTALL_RELEASE TRUE)
+ endif()
+ if(WINDOWS_INSTALL_DEBUG)
+ set(WINDOWS_CONFIGURATIONS "${WINDOWS_CONFIGURATIONS};Debug")
+ list(APPEND WINDOWS_SHARED_MANIFEST_DEBUG ${WINDOWS_INSTALL_FILES})
+ endif()
+ if(WINDOWS_INSTALL_RELEASE)
+ list(APPEND WINDOWS_SHARED_MANIFEST_RELEASE ${WINDOWS_INSTALL_FILES})
+ set(WINDOWS_CONFIGURATIONS "${WINDOWS_CONFIGURATIONS};Release;RelWithDebInfo;MinSizeRel")
+ endif()
+ install(FILES ${WINDOWS_INSTALL_FILES}
+ CONFIGURATIONS ${WINDOWS_CONFIGURATIONS}
+ DESTINATION "./blender.shared"
+ )
+endmacro()
+
+macro(windows_generate_manifest)
+ set(options)
+ set(oneValueArgs OUTPUT NAME)
+ set(multiValueArgs FILES)
+ cmake_parse_arguments(WINDOWS_MANIFEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+ set(MANIFEST_LIBS "")
+ foreach(lib ${WINDOWS_MANIFEST_FILES})
+ get_filename_component(filename ${lib} NAME)
+ set(MANIFEST_LIBS "${MANIFEST_LIBS} <file name=\"${filename}\"/>\n")
+ endforeach()
+ configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.manifest.in ${WINDOWS_MANIFEST_OUTPUT} @ONLY)
+endmacro()
+
+macro(windows_generate_shared_manifest)
+ windows_generate_manifest(
+ FILES "${WINDOWS_SHARED_MANIFEST_DEBUG}"
+ OUTPUT "${CMAKE_BINARY_DIR}/Debug/blender.shared.manifest"
+ NAME "blender.shared"
+ )
+ windows_generate_manifest(
+ FILES "${WINDOWS_SHARED_MANIFEST_RELEASE}"
+ OUTPUT "${CMAKE_BINARY_DIR}/Release/blender.shared.manifest"
+ NAME "blender.shared"
+ )
+ install(
+ FILES ${CMAKE_BINARY_DIR}/Release/blender.shared.manifest
+ DESTINATION "./blender.shared"
+ CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
+ )
+ install(
+ FILES ${CMAKE_BINARY_DIR}/Debug/blender.shared.manifest
+ DESTINATION "./blender.shared"
+ CONFIGURATIONS Debug
+ )
+endmacro()
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 28685671c33..4e3be0a9b0d 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -110,7 +110,41 @@ remove_cc_flag("/GR")
# Make the Windows 8.1 API available for use.
add_definitions(-D_WIN32_WINNT=0x603)
-include(build_files/cmake/platform/platform_win32_bundle_crt.cmake)
+
+# First generate the manifest for tests since it will not need the dependency on the CRT.
+configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/tests.exe.manifest @ONLY)
+
+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)
+
+ # ucrtbase(d).dll cannot be in the manifest, due to the way windows 10 handles
+ # redirects for this dll, for details see T88813.
+ foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
+ string(FIND ${lib} "ucrtbase" pos)
+ if(NOT pos EQUAL -1)
+ list(REMOVE_ITEM CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
+ install(FILES ${lib} DESTINATION . COMPONENT Libraries)
+ endif()
+ endforeach()
+ # Install the CRT to the blender.crt Sub folder.
+ install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ./blender.crt COMPONENT Libraries)
+
+ windows_generate_manifest(
+ FILES "${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}"
+ OUTPUT "${CMAKE_BINARY_DIR}/blender.crt.manifest"
+ NAME "blender.crt"
+ )
+
+ install(FILES ${CMAKE_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>")
+ set(BUNDLECRT "${BUNDLECRT}<dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"blender.shared\" 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)
+
+
remove_cc_flag("/MDd" "/MD" "/Zi")
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
deleted file mode 100644
index f197498d97b..00000000000
--- a/build_files/cmake/platform/platform_win32_bundle_crt.cmake
+++ /dev/null
@@ -1,56 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-# First generate the manifest for tests since it will not need the dependency on the CRT.
-configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/tests.exe.manifest @ONLY)
-
-# Always detect system libraries, since they are also used by oneAPI.
-# But don't always install them, only for WITH_WINDOWS_BUNDLE_CRT=ON.
-set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
-set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
-set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
-
-# This sometimes can change when updates are installed and the compiler version
-# changes, so test if it exists and if not, give InstallRequiredSystemLibraries
-# another chance to figure out the path.
-if(MSVC_REDIST_DIR AND NOT EXISTS "${MSVC_REDIST_DIR}")
- unset(MSVC_REDIST_DIR CACHE)
-endif()
-
-include(InstallRequiredSystemLibraries)
-
-if(WITH_WINDOWS_BUNDLE_CRT)
- # ucrtbase(d).dll cannot be in the manifest, due to the way windows 10 handles
- # redirects for this dll, for details see T88813.
- foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
- string(FIND ${lib} "ucrtbase" pos)
- if(NOT pos EQUAL -1)
- list(REMOVE_ITEM CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
- install(FILES ${lib} DESTINATION . COMPONENT Libraries)
- endif()
- endforeach()
- # 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 relatively 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)
- string(APPEND 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.manifest.in b/release/windows/manifest/Blender.manifest.in
new file mode 100644
index 00000000000..936494acc07
--- /dev/null
+++ b/release/windows/manifest/Blender.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="@WINDOWS_MANIFEST_NAME@" version="1.0.0.0" />
+ at MANIFEST_LIBS@</assembly>
\ No newline at end of file
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 5c51a934e08..b62cc8403e3 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -763,7 +763,6 @@ if(UNIX AND NOT APPLE)
unset(_suffix)
endif()
unset(_target_LIB)
-
endif()
endif()
@@ -774,22 +773,22 @@ if(UNIX AND NOT APPLE)
)
endif()
elseif(WIN32)
- install(
+ windows_install_shared_manifest(
FILES ${LIBDIR}/epoxy/bin/epoxy-0.dll
- DESTINATION ${TARGETDIR_LIB}
+ ALL
)
if(WITH_OPENMP AND MSVC_CLANG)
- install(
+ windows_install_shared_manifest(
FILES ${CLANG_OPENMP_DLL}
- DESTINATION ${TARGETDIR_LIB}
+ ALL
)
endif()
if(WITH_FFTW3)
- install(
+ windows_install_shared_manifest(
FILES ${LIBDIR}/fftw3/lib/libfftw3-3.dll
- DESTINATION ${TARGETDIR_LIB}
+ ALL
)
endif()
if(MSVC_ASAN)
@@ -804,34 +803,29 @@ elseif(WIN32)
"this is an optional component during the MSVC install, please install it"
)
endif()
- install(
+ windows_install_shared_manifest(
FILES ${ASAN_DLL}
- DESTINATION ${TARGETDIR_LIB}
- CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
+ RELEASE
)
- install(
+ windows_install_shared_manifest(
FILES ${ASAN_DEBUG_DLL}
- DESTINATION ${TARGETDIR_LIB}
- CONFIGURATIONS Debug
+ DEBUG
)
unset(ASAN_DLL)
unset(ASAN_DEBUG_DLL)
endif()
-
if(WITH_GMP)
- install(
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list