Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-08-18 18:07:10 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-08-23 16:27:16 +0300
commita87d3edb9898bc6b285e5b3742566f6783ea6d92 (patch)
tree27eedbfc3a7e6d169104df719231a707ed25c595 /build_files/cmake/platform/platform_apple.cmake
parentafb74149c16ab0bb43b157db170ef2e48f7f8558 (diff)
Build: add system for shipping with dynamic libraries on Linux and macOS
PLATFORM_BUNDLED_LIBRARIES gathers shared libraries that will be installed to the lib/ folder. The Blender executable gets a relative rpath pointing to this folder as part of the install step. The build rpath is different and uses absolute paths, so that it works for executables like tests that are in different locations, and to support the case where the build and install folders are different. The system is already used for the OpenMP library on macOS. But on Linux it will only kick in once we start using shared libraries for dependencies. This also removes Mesa libraries from the old location, as these would cause Blender to start with software OpenGL. Ref T99618
Diffstat (limited to 'build_files/cmake/platform/platform_apple.cmake')
-rw-r--r--build_files/cmake/platform/platform_apple.cmake43
1 files changed, 33 insertions, 10 deletions
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index f39cb7a4951..bc5baf43530 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -21,6 +21,18 @@ function(print_found_status
endif()
endfunction()
+# Utility to install precompiled shared libraries.
+macro(add_bundled_libraries library)
+ if(EXISTS ${LIBDIR})
+ set(_library_dir ${LIBDIR}/${library}/lib)
+ file(GLOB _all_library_versions ${_library_dir}/*\.dylib*)
+ list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_all_library_versions})
+ list(APPEND PLATFORM_BUNDLED_LIBRARY_DIRS ${_library_dir})
+ unset(_all_library_versions)
+ unset(_library_dir)
+ endif()
+endmacro()
+
# ------------------------------------------------------------------------
# Find system provided libraries.
@@ -415,6 +427,7 @@ if(WITH_OPENMP)
set(OpenMP_LIBRARY_DIR "${LIBDIR}/openmp/lib/")
set(OpenMP_LINKER_FLAGS "-L'${OpenMP_LIBRARY_DIR}' -lomp")
set(OpenMP_LIBRARY "${OpenMP_LIBRARY_DIR}/libomp.dylib")
+ add_bundled_libraries(openmp)
endif()
endif()
@@ -504,17 +517,27 @@ if(WITH_COMPILER_CCACHE)
endif()
endif()
-# For binaries that are built but not installed (also not distributed) (datatoc,
-# makesdna, tests, etc.), we add an rpath to the OpenMP library dir through
-# CMAKE_BUILD_RPATH. This avoids having to make many copies of the dylib next to each binary.
-#
-# For the installed Python module and installed Blender executable, CMAKE_INSTALL_RPATH
-# is modified to find the dylib in an adjacent folder. Install step puts the libraries there.
-set(CMAKE_SKIP_BUILD_RPATH FALSE)
-list(APPEND CMAKE_BUILD_RPATH "${OpenMP_LIBRARY_DIR}")
+if(WITH_COMPILER_ASAN)
+ list(APPEND PLATFORM_BUNDLED_LIBRARIES ${COMPILER_ASAN_LIBRARY})
+endif()
-set(CMAKE_SKIP_INSTALL_RPATH FALSE)
-list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
+if(PLATFORM_BUNDLED_LIBRARIES)
+ # For the installed Python module and installed Blender executable, we set the
+ # rpath to the location where install step will copy the shared libraries.
+ set(CMAKE_SKIP_INSTALL_RPATH FALSE)
+ if(WITH_PYTHON_MODULE)
+ list(APPEND CMAKE_INSTALL_RPATH "@loader_path/lib")
+ else()
+ list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/lib")
+ endif()
+
+ # For binaries that are built but not installed (like makesdan or tests), we add
+ # the original directory of all shared libraries to the rpath. This is needed because
+ # these can be in different folders, and because the build and install folder may be
+ # different.
+ set(CMAKE_SKIP_BUILD_RPATH FALSE)
+ list(APPEND CMAKE_BUILD_RPATH ${PLATFORM_BUNDLED_LIBRARY_DIRS})
+endif()
# Same as `CFBundleIdentifier` in Info.plist.
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.blenderfoundation.blender")