Build: Fix various issue for 4.2 macOS library update

* Auto patch MaterialX cmake config for stripping version from dylib
* Add x265 library
* Fix harvest of OIDN cmake config

Ref #123348
This commit is contained in:
Brecht Van Lommel 2024-06-21 13:55:17 +02:00
parent e72730d763
commit 3b4d03968b
3 changed files with 28 additions and 9 deletions

@ -85,11 +85,7 @@ else()
cmake_policy(SET CMP0009 NEW)\n
file(GLOB_RECURSE shared_libs ${HARVEST_TARGET}/${to}/${pattern}) \n
foreach(f \${shared_libs}) \n
if(IS_SYMLINK \${f})\n
if(APPLE)\n
file(REMOVE_RECURSE \${f})
endif()\n
else()\n
if((NOT IS_SYMLINK \${f}) OR APPLE)\n
execute_process(COMMAND ${set_rpath_cmd} \${f}) \n
endif()\n
endforeach()")
@ -230,7 +226,7 @@ else()
)
harvest(openimagedenoise/include openimagedenoise/include "*")
harvest_rpath_lib(openimagedenoise/lib openimagedenoise/lib "*${SHAREDLIBEXT}*")
harvest(openimagedenoise/lib/cmake/OpenImageDenoise-${OIDN_VERSION} openimagedenoise/lib/cmake/OpenImageDenoise "*.cmake")
harvest(openimagedenoise/lib/cmake openimagedenoise/lib/cmake)
harvest(embree/include embree/include "*.h")
harvest(embree/lib embree/lib "*.a")
harvest_rpath_lib(embree/lib embree/lib "*${SHAREDLIBEXT}*")
@ -292,9 +288,9 @@ else()
)
harvest(usd/plugin usd/plugin "*")
harvest(materialx/include materialx/include "*.h")
harvest(materialx/lib/cmake/MaterialX materialx/lib/cmake/MaterialX "*.cmake")
harvest_rpath_lib(materialx/lib materialx/lib "*${SHAREDLIBEXT}*")
harvest(materialx/libraries materialx/libraries "*")
harvest(materialx/lib/cmake/MaterialX materialx/lib/cmake/MaterialX "*.cmake")
harvest_rpath_python(
materialx/python/MaterialX
python/lib/python${PYTHON_SHORT_VERSION}/site-packages/MaterialX

@ -6,6 +6,7 @@
# macOS utility to remove all `rpaths` and add a new one.
import os
import pathlib
import re
import subprocess
import sys
@ -20,8 +21,28 @@ def strip_lib_version(name):
return name
# Patch cmake config to match rename
def update_cmake_config(oldfile, newfile):
for cmakefile in oldfile.parent.glob("cmake/*/*.cmake"):
text = cmakefile.read_text()
text = text.replace(oldfile.name, newfile.name)
cmakefile.write_text(text)
rpath = sys.argv[1]
file = sys.argv[2]
new_file = strip_lib_version(file)
file = pathlib.Path(file)
new_file = pathlib.Path(new_file)
# Update cmake config files.
update_cmake_config(file, new_file)
# Remove if symlink.
if file.is_symlink():
os.remove(file)
sys.exit(0)
# Find existing rpaths and delete them one by one.
p = subprocess.run(['otool', '-l', file], capture_output=True)
@ -44,7 +65,6 @@ for i, token in enumerate(tokens):
subprocess.run(['install_name_tool', '-change', token, new_token, file])
# Strip version from library itself.
new_file = strip_lib_version(file)
new_id = '@rpath/' + os.path.basename(new_file)
new_id = '@rpath/' + new_file.name
os.rename(file, new_file)
subprocess.run(['install_name_tool', '-id', new_id, new_file])

@ -174,6 +174,9 @@ if(WITH_CODEC_FFMPEG)
if(EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a)
list(APPEND FFMPEG_FIND_COMPONENTS aom)
endif()
if(EXISTS ${LIBDIR}/ffmpeg/lib/libx265.a)
list(APPEND FFMPEG_FIND_COMPONENTS x265)
endif()
if(EXISTS ${LIBDIR}/ffmpeg/lib/libxvidcore.a)
list(APPEND FFMPEG_FIND_COMPONENTS xvidcore)
endif()