diff options
Diffstat (limited to 'build_files')
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 43 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_unix.cmake | 22 |
2 files changed, 55 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") diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index f18638dfa6b..080cbfd6a16 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -81,6 +81,15 @@ macro(find_package_wrapper) endif() endmacro() +# Utility to install precompiled shared libraries. +macro(add_bundled_libraries library) + if(EXISTS ${LIBDIR}) + file(GLOB _all_library_versions ${LIBDIR}/${library}/lib/*\.so*) + list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_all_library_versions}) + unset(_all_library_versions) + endif() +endmacro() + # ---------------------------------------------------------------------------- # Precompiled Libraries # @@ -971,3 +980,16 @@ function(CONFIGURE_ATOMIC_LIB_IF_NEEDED) endfunction() CONFIGURE_ATOMIC_LIB_IF_NEEDED() + +if(PLATFORM_BUNDLED_LIBRARIES) + # For the installed Python module and installed Blender executable, we set the + # rpath to the relative path where the install step will copy the shared libraries. + set(CMAKE_SKIP_INSTALL_RPATH FALSE) + list(APPEND CMAKE_INSTALL_RPATH $ORIGIN/lib) + + # For executables that are built but not installed (mainly tests) we set an absolute + # rpath to the lib folder. 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 $ORIGIN/lib ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib) +endif() |