Fix Python Module build on Windows

Don't install libraries in blender.shared and don't generate manifest
as it's not working and not important to have a clean directory here.

Always detect MSVC_REDIST_DIR as it is used by oneAPI. The way
InstallRequiredSystemLibraries is called it already only sets some
variables and doesn't install anything by itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/105999
This commit is contained in:
Brecht Van Lommel 2023-03-28 16:32:25 +02:00 committed by Brecht Van Lommel
parent ac0ed09735
commit 6e51f8d202
3 changed files with 60 additions and 38 deletions

View File

@ -1299,16 +1299,29 @@ macro(windows_install_shared_manifest)
endif() endif()
if(WINDOWS_INSTALL_DEBUG) if(WINDOWS_INSTALL_DEBUG)
set(WINDOWS_CONFIGURATIONS "${WINDOWS_CONFIGURATIONS};Debug") set(WINDOWS_CONFIGURATIONS "${WINDOWS_CONFIGURATIONS};Debug")
list(APPEND WINDOWS_SHARED_MANIFEST_DEBUG ${WINDOWS_INSTALL_FILES})
endif() endif()
if(WINDOWS_INSTALL_RELEASE) if(WINDOWS_INSTALL_RELEASE)
list(APPEND WINDOWS_SHARED_MANIFEST_RELEASE ${WINDOWS_INSTALL_FILES})
set(WINDOWS_CONFIGURATIONS "${WINDOWS_CONFIGURATIONS};Release;RelWithDebInfo;MinSizeRel") set(WINDOWS_CONFIGURATIONS "${WINDOWS_CONFIGURATIONS};Release;RelWithDebInfo;MinSizeRel")
endif() endif()
install(FILES ${WINDOWS_INSTALL_FILES} if(NOT WITH_PYTHON_MODULE)
CONFIGURATIONS ${WINDOWS_CONFIGURATIONS} # Blender executable with manifest.
DESTINATION "./blender.shared" if(WINDOWS_INSTALL_DEBUG)
) list(APPEND WINDOWS_SHARED_MANIFEST_DEBUG ${WINDOWS_INSTALL_FILES})
endif()
if(WINDOWS_INSTALL_RELEASE)
list(APPEND WINDOWS_SHARED_MANIFEST_RELEASE ${WINDOWS_INSTALL_FILES})
endif()
install(FILES ${WINDOWS_INSTALL_FILES}
CONFIGURATIONS ${WINDOWS_CONFIGURATIONS}
DESTINATION "./blender.shared"
)
else()
# Python module without manifest.
install(FILES ${WINDOWS_INSTALL_FILES}
CONFIGURATIONS ${WINDOWS_CONFIGURATIONS}
DESTINATION "./bpy"
)
endif()
endmacro() endmacro()
macro(windows_generate_manifest) macro(windows_generate_manifest)
@ -1325,24 +1338,28 @@ macro(windows_generate_manifest)
endmacro() endmacro()
macro(windows_generate_shared_manifest) macro(windows_generate_shared_manifest)
windows_generate_manifest( if(WINDOWS_SHARED_MANIFEST_DEBUG)
FILES "${WINDOWS_SHARED_MANIFEST_DEBUG}" windows_generate_manifest(
OUTPUT "${CMAKE_BINARY_DIR}/Debug/blender.shared.manifest" FILES "${WINDOWS_SHARED_MANIFEST_DEBUG}"
NAME "blender.shared" OUTPUT "${CMAKE_BINARY_DIR}/Debug/blender.shared.manifest"
) NAME "blender.shared"
windows_generate_manifest( )
FILES "${WINDOWS_SHARED_MANIFEST_RELEASE}" install(
OUTPUT "${CMAKE_BINARY_DIR}/Release/blender.shared.manifest" FILES ${CMAKE_BINARY_DIR}/Debug/blender.shared.manifest
NAME "blender.shared" DESTINATION "./blender.shared"
) CONFIGURATIONS Debug
install( )
FILES ${CMAKE_BINARY_DIR}/Release/blender.shared.manifest endif()
DESTINATION "./blender.shared" if(WINDOWS_SHARED_MANIFEST_RELEASE)
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel windows_generate_manifest(
) FILES "${WINDOWS_SHARED_MANIFEST_RELEASE}"
install( OUTPUT "${CMAKE_BINARY_DIR}/Release/blender.shared.manifest"
FILES ${CMAKE_BINARY_DIR}/Debug/blender.shared.manifest NAME "blender.shared"
DESTINATION "./blender.shared" )
CONFIGURATIONS Debug install(
) FILES ${CMAKE_BINARY_DIR}/Release/blender.shared.manifest
DESTINATION "./blender.shared"
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
endif()
endmacro() endmacro()

View File

@ -114,12 +114,13 @@ add_definitions(-D_WIN32_WINNT=0x603)
# First generate the manifest for tests since it will not need the dependency on the CRT. # 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) 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) # Always detect CRT paths, but only manually install with WITH_WINDOWS_BUNDLE_CRT.
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP}) set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
include(InstallRequiredSystemLibraries) include(InstallRequiredSystemLibraries)
if(WITH_WINDOWS_BUNDLE_CRT)
# ucrtbase(d).dll cannot be in the manifest, due to the way windows 10 handles # ucrtbase(d).dll cannot be in the manifest, due to the way windows 10 handles
# redirects for this dll, for details see #88813. # redirects for this dll, for details see #88813.
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
@ -141,7 +142,9 @@ if(WITH_WINDOWS_BUNDLE_CRT)
install(FILES ${CMAKE_BINARY_DIR}/blender.crt.manifest DESTINATION ./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 "<dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"blender.crt\" version=\"1.0.0.0\" /></dependentAssembly></dependency>")
endif() endif()
set(BUNDLECRT "${BUNDLECRT}<dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"blender.shared\" version=\"1.0.0.0\" /></dependentAssembly></dependency>") if(NOT WITH_PYTHON_MODULE)
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) configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/blender.exe.manifest @ONLY)

View File

@ -353,10 +353,12 @@ elseif(WIN32)
set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/bpy/${BLENDER_VERSION}) set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/bpy/${BLENDER_VERSION})
# Important the DLL's are next to `__init__.pyd` otherwise it won't load. # Important the DLL's are next to `__init__.pyd` otherwise it won't load.
set(TARGETDIR_LIB ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/bpy) set(TARGETDIR_LIB ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/bpy)
set(TARGETDIR_EXE ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/bpy)
else() else()
set(TARGETDIR_VER ${BLENDER_VERSION}) set(TARGETDIR_VER ${BLENDER_VERSION})
set(TARGETDIR_TEXT .) set(TARGETDIR_TEXT .)
set(TARGETDIR_LIB .) set(TARGETDIR_LIB ./blender.shared)
set(TARGETDIR_EXE .)
endif() endif()
elseif(APPLE) elseif(APPLE)
if(WITH_PYTHON_MODULE) if(WITH_PYTHON_MODULE)
@ -1006,7 +1008,7 @@ elseif(WIN32)
FILES FILES
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}.dll ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}.dll
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3.dll ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3.dll
DESTINATION ${TARGETDIR_LIB} DESTINATION ${TARGETDIR_EXE}
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
) )
@ -1014,7 +1016,7 @@ elseif(WIN32)
FILES FILES
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}_d.dll ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}_d.dll
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3_d.dll ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3_d.dll
DESTINATION ${TARGETDIR_LIB} DESTINATION ${TARGETDIR_EXE}
CONFIGURATIONS Debug CONFIGURATIONS Debug
) )
endif() endif()
@ -1252,7 +1254,7 @@ elseif(WIN32)
${CMAKE_SOURCE_DIR}/release/windows/batch/blender_factory_startup.cmd ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_factory_startup.cmd
${CMAKE_SOURCE_DIR}/release/windows/batch/blender_oculus.cmd ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_oculus.cmd
${CMAKE_SOURCE_DIR}/release/windows/batch/oculus.json ${CMAKE_SOURCE_DIR}/release/windows/batch/oculus.json
DESTINATION ${TARGETDIR_LIB} DESTINATION ${TARGETDIR_EXE}
) )
endif() endif()
@ -1280,7 +1282,7 @@ elseif(WIN32)
if(PLATFORM_BUNDLED_LIBRARIES) if(PLATFORM_BUNDLED_LIBRARIES)
install( install(
FILES ${PLATFORM_BUNDLED_LIBRARIES} FILES ${PLATFORM_BUNDLED_LIBRARIES}
DESTINATION ${TARGETDIR_LIB} DESTINATION ${TARGETDIR_EXE}
) )
endif() endif()
elseif(APPLE) elseif(APPLE)
@ -1513,7 +1515,7 @@ if((DEFINED LIBDIR) AND TARGETDIR_LIB)
) )
install(DIRECTORY install(DIRECTORY
${USD_LIBRARY_DIR}/usd ${USD_LIBRARY_DIR}/usd
DESTINATION "./blender.shared" DESTINATION ${TARGETDIR_LIB}
) )
elseif(USD_PYTHON_SUPPORT) elseif(USD_PYTHON_SUPPORT)
install(DIRECTORY install(DIRECTORY