Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pxrTargets.cmake contains absolute build paths #1025

Open
mistafunk opened this issue Nov 5, 2019 · 6 comments
Open

pxrTargets.cmake contains absolute build paths #1025

mistafunk opened this issue Nov 5, 2019 · 6 comments
Labels
build Build-related issue/PR

Comments

@mistafunk
Copy link

mistafunk commented Nov 5, 2019

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:

CMake Error in usd/CMakeLists.txt:
   Imported target "tf" includes non-existent path
    "/xxx/boost-xxx/include"
   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
   * The path was deleted, renamed, or moved to another location.
   * An install or uninstall procedure did not complete successfully.
   * The installation package was faulty and references files it does not provide.

"/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

  1. Setup cmake to build USD static libraries:
   -DBUILD_SHARED_LIBS=0
   -DPXR_BUILD_MONOLITHIC=0
   -DPXR_ENABLE_PYTHON_SUPPORT=0
   -DPXR_BUILD_IMAGING=0
   -DPXR_BUILD_TESTS=0
   -DBOOST_ROOT=xxx
   -DBoost_DEBUG=1
   -DBoost_NO_SYSTEM_PATHS=1
   -DBoost_ADDITIONAL_VERSIONS="1.71.1;1.71.0;1.71"
   -DTBB_LIBRARY=xxx -DTBB_tbb_LIBRARY=xxx -DTBB_INCLUDE_DIR=xxx
   -DOPENEXR_LOCATION=xxx
   -DGLEW_LOCATION=xxx
   -DCMAKE_INSTALL_PREFIX=xxx
   -DCMAKE_BUILD_TYPE=Debug
   -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
   /path/to/USD-19.11
  1. ninja install
  2. Try to consume the pxr target with find_package

System Information (OS, Hardware)

CentOS 7.6

Package Versions

USD 19.11

@mistafunk mistafunk changed the title Unexpected absolute build include paths in generated pxrTargets.cmake pxrTargets.cmake contains absolute build paths Nov 5, 2019
@jilliene
Copy link

jilliene commented Nov 7, 2019

Filed as internal issue #USD-5682

@moddyz
Copy link
Contributor

moddyz commented Oct 8, 2020

Just hit this too 😄 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.

@JGamache-autodesk
Copy link
Contributor

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.

@JGamache-autodesk
Copy link
Contributor

@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.

@carsonbrownlee
Copy link

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.

@manuelkoester
Copy link

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.

https://github.com/adobe/USD-Fileformat-plugins/blob/main/.github/workflows/create-usd-release.yml#L158

@asluk asluk added the build Build-related issue/PR label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build-related issue/PR
Projects
None yet
Development

No branches or pull requests

7 participants