Page MenuHome

Build: move USD whole archive linking logic to FindUSD.cmake
Changes PlannedPublic

Authored by Brecht Van Lommel (brecht) on Apr 29 2022, 12:18 AM.

Details

Summary

To be shared with Cycles standalone that will get USD support.

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested review of this revision.Apr 29 2022, 12:18 AM
Brecht Van Lommel (brecht) created this revision.
Ray Molenkamp (LazyDodo) added inline comments.
build_files/cmake/Modules/FindUSD.cmake
63

This likely won't do the trick for windows, the magic on windows is happening just above the chunk you took out in source/blender/io/usd/CMakeLists.txt

Blind update to test Windows on buildbot, no need to review yet.

Brecht Van Lommel (brecht) planned changes to this revision.Apr 29 2022, 1:54 AM

This is not working on Windows, will need to look into it more closely.

i'd probably try something like this near the end of FindUSD.cmake (done in the editor here, not tested, likely contains a typo or two)

add_library(USD::USD INTERFACE)
if(WIN32)
  set_property(TARGET USD::USD APPEND_STRING PROPERTY INTERFACE_LINK_OPTIONS "$<$<CONFIG:Debug>:/WHOLEARCHIVE:${USD_DEBUG_LIB}>")
  set_property(TARGET USD::USD APPEND_STRING PROPERTY INTERFACE_LINK_OPTIONS "$<$<CONFIG:Release>:/WHOLEARCHIVE:${USD_RELEASE_LIB}>")
  set_property(TARGET USD::USD APPEND_STRING PROPERTY INTERFACE_LINK_OPTIONS "$<$<CONFIG:RelWithDebInfo>:/WHOLEARCHIVE:${USD_RELEASE_LIB}>")
  set_property(TARGET USD::USD APPEND_STRING PROPERTY INTERFACE_LINK_OPTIONS "$<$<CONFIG:MinSizeRel>:/WHOLEARCHIVE:${USD_RELEASE_LIB}>")
endif()

# Source: https://github.com/PixarAnimationStudios/USD/blob/master/BUILDING.md#linking-whole-archives
if(WIN32)
  target_link_libraries(USD::USD INTERFACE ${USD_LIBRARIES})
elseif(APPLE)
  target_link_libraries(USD::USD INTERFACE -Wl,-force_load ${USD_LIBRARIES})
elseif(UNIX)
  target_link_libraries(USD::USD INTERFACE "-Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive ${TBB_LIBRARIES}")
else()
  message(FATAL_ERROR "Unknown how to link USD with your compiler ${CMAKE_CXX_COMPILER_ID}")
endif()

and linking against USD::USD in the client code rather than ${USD_LIBRARIES}

after thought: maybe BLENDER::USD ? we really haven't gotten any deps as modern targets yet so i'm kinda making it up as we go.