Open mistafunk opened 5 years ago
Filed as internal issue #USD-5682
Just hit this too :smile: definitely limits the portability of pxrTargets.cmake
when attempting to consume it directly.
It seems like the absolute paths are due to the usage of target_include_directories(... PUBLIC ...)
.
On a local build - attempting to privatize target_include_directories
resulted in a lot of the downstream libraries which were expecting to inherit required includes to fail compilation.
Had that issue very recently with MaterialX. The solution was annoyingly simple once I finally found it. All install
destination paths must be relative. This will allow the CMake generator to issue relocatable code that does not contain absolute paths. All that was needed was to remove a lot of ${CMAKE_INSTALL_PATH}
and it worked.
@moddyz Got the same issue when building USD with MaterialX. Any downstream application that links with the hdSt
library will fail to link unless that downstream application also happens to use MaterialX. This is due to MaterialX libraries being declared PUBLIC, which adds these libraries to the list that the downstream client requires, even when not needed.
set_target_properties(hdSt PROPERTIES
INTERFACE_LINK_LIBRARIES "hio;garch;glf;hd;hgiGL;sdr;tf;trace;hdMtlx;${PXR_USD_LOCATION}/lib/osdCPU.lib;${PXR_USD_LOCATION}/lib/osdGPU.lib;MaterialXGenShader;MaterialXRender;MaterialXCore;MaterialXFormat;MaterialXGenGlsl"
)
The MaterialX libraries should have been declared PRIVATE instead.
this still seems to be an issue. A simple external fix is to run a string replace on pxrTargets.cmake to replace the absolute path with ${_IMPORT_PREFIX}. I'm not sure how to fix this in USD itself, other than perhaps JG's suggestion above.
This still seems to be an issue, but I just wanted to leave by this workaround example from the Adobe USD-Fileformat-plugins repository here, which is using github actions to build USD.
Description of Issue
After
make install
USD,cmake/pxrTargets.cmake
unexpectedly contains absolute paths. In an consuming cmake script,find_package(pxr CONFIG ...)
fails with:"/xxx/boost-xxx/include" is an absolute path to the boost include directory on our build server which obviously does not exist anymore when consuming USD in a downstream build system.
Steps to Reproduce
ninja install
find_package
System Information (OS, Hardware)
CentOS 7.6
Package Versions
USD 19.11