From 2774d2bd27b05bf7f94d6f7b341d5d703ad93c5e Mon Sep 17 00:00:00 2001 From: Michael MIGLIORE Date: Wed, 14 Jun 2023 21:39:27 +0200 Subject: [PATCH] [usd] Improve CMake and fix Linux (#31807) Co-authored-by: Zhao Liu --- ports/usd/portfile.cmake | 61 ++++++++++++++++++++++------------------ ports/usd/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/u-/usd.json | 5 ++++ 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/ports/usd/portfile.cmake b/ports/usd/portfile.cmake index 7ba53a4444..854ddb23f1 100644 --- a/ports/usd/portfile.cmake +++ b/ports/usd/portfile.cmake @@ -2,7 +2,7 @@ set(VCPKG_POLICY_EMPTY_PACKAGE enabled) message(STATUS [=[ -The usd port does not work the the version of Threading Building Blocks (tbb) currently chosen by vcpkg's baselines, +The usd port does not work with the version of Threading Building Blocks (tbb) currently chosen by vcpkg's baselines, and does not expect to be updated to work with current versions soon. See https://github.com/PixarAnimationStudios/USD/issues/1600 @@ -43,6 +43,10 @@ vcpkg_cmake_configure( vcpkg_cmake_install() +# The CMake files installation is not standard in USD and will install pxrConfig.cmake in the prefix root and +# pxrTargets.cmake in "cmake" so we are moving pxrConfig.cmake in the same folder and patch the path to pxrTargets.cmake +vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/pxrConfig.cmake "/cmake/pxrTargets.cmake" "/pxrTargets.cmake") + file( RENAME "${CURRENT_PACKAGES_DIR}/pxrConfig.cmake" @@ -50,39 +54,40 @@ file( vcpkg_cmake_config_fixup(CONFIG_PATH cmake PACKAGE_NAME pxr) -vcpkg_copy_pdbs() - # Remove duplicates in debug folder file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/pxrConfig.cmake) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) # Handle copyright -file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) +vcpkg_install_copyright(FILE_LIST ${SOURCE_PATH}/LICENSE.txt) -# Move all dlls to bin -file(GLOB RELEASE_DLL ${CURRENT_PACKAGES_DIR}/lib/*.dll) -file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin) -file(GLOB DEBUG_DLL ${CURRENT_PACKAGES_DIR}/debug/lib/*.dll) -file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin) -foreach(CURRENT_FROM ${RELEASE_DLL} ${DEBUG_DLL}) - string(REPLACE "/lib/" "/bin/" CURRENT_TO ${CURRENT_FROM}) - file(RENAME ${CURRENT_FROM} ${CURRENT_TO}) -endforeach() +if(VCPKG_TARGET_IS_WINDOWS) + # Move all dlls to bin + file(GLOB RELEASE_DLL ${CURRENT_PACKAGES_DIR}/lib/*.dll) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin) + file(GLOB DEBUG_DLL ${CURRENT_PACKAGES_DIR}/debug/lib/*.dll) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin) + foreach(CURRENT_FROM ${RELEASE_DLL} ${DEBUG_DLL}) + string(REPLACE "/lib/" "/bin/" CURRENT_TO ${CURRENT_FROM}) + file(RENAME ${CURRENT_FROM} ${CURRENT_TO}) + endforeach() -function(file_replace_regex filename match_string replace_string) - file(READ ${filename} _contents) - string(REGEX REPLACE "${match_string}" "${replace_string}" _contents "${_contents}") - file(WRITE ${filename} "${_contents}") -endfunction() + vcpkg_copy_pdbs() -# fix dll path for cmake -file_replace_regex(${CURRENT_PACKAGES_DIR}/share/pxr/pxrConfig.cmake "/cmake/pxrTargets.cmake" "/pxrTargets.cmake") -file_replace_regex(${CURRENT_PACKAGES_DIR}/share/pxr/pxrTargets-debug.cmake "debug/lib/([a-zA-Z0-9_]+)\\.dll" "debug/bin/\\1.dll") -file_replace_regex(${CURRENT_PACKAGES_DIR}/share/pxr/pxrTargets-release.cmake "lib/([a-zA-Z0-9_]+)\\.dll" "bin/\\1.dll") + function(file_replace_regex filename match_string replace_string) + file(READ ${filename} _contents) + string(REGEX REPLACE "${match_string}" "${replace_string}" _contents "${_contents}") + file(WRITE ${filename} "${_contents}") + endfunction() -# fix plugInfo.json for runtime -file(GLOB_RECURSE PLUGINFO_FILES ${CURRENT_PACKAGES_DIR}/lib/usd/*/resources/plugInfo.json) -file(GLOB_RECURSE PLUGINFO_FILES_DEBUG ${CURRENT_PACKAGES_DIR}/debug/lib/usd/*/resources/plugInfo.json) -foreach(PLUGINFO ${PLUGINFO_FILES} ${PLUGINFO_FILES_DEBUG}) - file_replace_regex(${PLUGINFO} [=["LibraryPath": "../../([a-zA-Z0-9_]+).dll"]=] [=["LibraryPath": "../../../bin/\1.dll"]=]) -endforeach() + # fix dll path for cmake + file_replace_regex(${CURRENT_PACKAGES_DIR}/share/pxr/pxrTargets-debug.cmake "debug/lib/([a-zA-Z0-9_]+)\\.dll" "debug/bin/\\1.dll") + file_replace_regex(${CURRENT_PACKAGES_DIR}/share/pxr/pxrTargets-release.cmake "lib/([a-zA-Z0-9_]+)\\.dll" "bin/\\1.dll") + + # fix plugInfo.json for runtime + file(GLOB_RECURSE PLUGINFO_FILES ${CURRENT_PACKAGES_DIR}/lib/usd/*/resources/plugInfo.json) + file(GLOB_RECURSE PLUGINFO_FILES_DEBUG ${CURRENT_PACKAGES_DIR}/debug/lib/usd/*/resources/plugInfo.json) + foreach(PLUGINFO ${PLUGINFO_FILES} ${PLUGINFO_FILES_DEBUG}) + file_replace_regex(${PLUGINFO} [=["LibraryPath": "../../([a-zA-Z0-9_]+).dll"]=] [=["LibraryPath": "../../../bin/\1.dll"]=]) + endforeach() +endif() diff --git a/ports/usd/vcpkg.json b/ports/usd/vcpkg.json index 5cd95382f3..be8e363dfa 100644 --- a/ports/usd/vcpkg.json +++ b/ports/usd/vcpkg.json @@ -1,7 +1,7 @@ { "name": "usd", "version": "23.5", - "port-version": 1, + "port-version": 2, "description": "Universal Scene Description (USD) is an efficient, scalable system for authoring, reading, and streaming time-sampled scene description for interchange between graphics applications.", "homepage": "https://github.com/PixarAnimationStudios/USD", "license": null, diff --git a/versions/baseline.json b/versions/baseline.json index 9a24200351..8d246b92eb 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -8294,7 +8294,7 @@ }, "usd": { "baseline": "23.5", - "port-version": 1 + "port-version": 2 }, "usockets": { "baseline": "0.8.6", diff --git a/versions/u-/usd.json b/versions/u-/usd.json index 5ca746912c..9a872953e7 100644 --- a/versions/u-/usd.json +++ b/versions/u-/usd.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "b5cb814be5a5aec9d600aeb98cd2126f407ca062", + "version": "23.5", + "port-version": 2 + }, { "git-tree": "cfe836715c8cf43db76006deffa234cecf77745c", "version": "23.5",