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

add USD_INCLUDE_DIR to includes #5

Closed
wants to merge 1 commit into from

Conversation

pmolodo
Copy link
Contributor

@pmolodo pmolodo commented Aug 2, 2019

So, this may not be necessary / may be due to a problem on my part. But when I tried to build, it immediately failed, because none of the USD headers could be find. I couldn't find anywhere in the CMakeLists files that seemed to explicitly add the USD_INCLUDE_DIR to the include path... and when I did, it worked.

However, I assume there must be some other way this is being done for you folks, or else you'd obviously never have been able to build... so maybe I'm missing something?

@HamedSabri-adsk
Copy link
Contributor

We have always been able to build master and didn't have to call include_directories(${USD_INCLUDE_DIR}) explicitly to the include path.

@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 5, 2019

Odd - I've tried to build it twice now - once with Linux work / luma desktop, once with my own Mac laptop... both failed to find the pixar headers, even though they are passed the USD root (and the find_package works).

I'll guess we'll have to see what other people find?

@mattyjams
Copy link
Contributor

I started looking into building this for Linux on the Pixar side and found that I also had to apply this patch from @elrond79 to get it to find the USD headers. I haven't looked in detail yet to try to figure out what might be different about how we're building it.

pmolodo added a commit to LumaPictures/maya-usd that referenced this pull request Aug 7, 2019
* Make sure the build and install folders have the variant (#2)
* Enable generating compile_commands.json by default
* Make sure the build and install folders have the variant 
* Fix typo in ReadMe
* temporarily revert line endings to windows to do merge
* standardize on linux-style line endings (newline only)
@HamedSabri-adsk
Copy link
Contributor

Fair enough. It would be nice to understand why things build for some of us and not the others.

@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 7, 2019

Did you mean to close this without merging?

@HamedSabri-adsk
Copy link
Contributor

I didn't mean to close it. Not sure how this was closed? I am going to look at a few things tomorrow to see if I can find a logical answer for this.

@HamedSabri-adsk
Copy link
Contributor

Can you please send me your build_log.txt when the build fails?

@mattyjams
Copy link
Contributor

Here's the build_log.txt I get if I don't apply the change in this PR:

build_log.txt

@HamedSabri-adsk
Copy link
Contributor

Thanks. I am interested to know the list of subdirectories under "/pixar/ws/trees/mattjohnson/usd_open_source/inst" which you have set for PXR_USD_LOCATION variable.

Could you add below messages in FindUSD.cmake, right before find_package_handle_standard_args call ( line 70 ) and send me your build.log again?

message(STATUS "USD include dir: ${USD_INCLUDE_DIR}")
message(STATUS "USD library dir: ${USD_LIBRARY_DIR}")
message(STATUS "USD version: ${USD_VERSION}")

Here is my build log with ${USD_INCLUDE_DIR} ${USD_LIBRARY_DIR} ${USD_VERSION} variables printed out.

build_log.txt

@mattyjams
Copy link
Contributor

Sure thing. Here is the output from those messages:

-- USD include dir: /pixar/ws/trees/mattjohnson/usd_open_source/inst/include
-- USD library dir: /pixar/ws/trees/mattjohnson/usd_open_source/inst/lib
-- USD version: 0.19.10

And that is indeed where core USD is installed. There are files at paths like these:
/pixar/ws/trees/mattjohnson/usd_open_source/inst/include/pxr/pxr.h
/pixar/ws/trees/mattjohnson/usd_open_source/inst/lib/libusd.so

@HamedSabri-adsk
Copy link
Contributor

Good! So the USD include and lib are found and the subdirectories that you are showing looks good to me.

The only thing that is a bit troubling is the USD version that you are using. Currently master branch should be build against USD v19.05 and that's what we all have been using. We will be updating the docs to avoid any confusion. Sorry about that!

Now, still with v0.19.10, you shouldn't get errors about missing headers. Anyways, it is worth the try if you switch to v0.19.5

One more question, what version of CMake are you using?

@mattyjams
Copy link
Contributor

mattyjams commented Aug 9, 2019

Hmm. Well to answer your last question first:
> cmake3 --version
cmake3 version 3.13.5

We have it installed as cmake3 since we also have a 2.8 version of cmake installed in our environment as cmake, so I had to modify the build script to invoke it as cmake3.

As to the USD version, we (Pixar) don't keep older releases of USD around and are effectively always working off of the dev branch. Internally, USD is distributed along with the rest of our software through a different release process, so there is no real mapping between what production is using and a public release version. For developers, we're continually working against and building the latest of both core USD and the Maya/USD integration, so that's the workflow we're aiming to preserve. Changes we check in internally were propagated to the dev branch of the public GitHub repo so that it was usually never more than a few days behind where we were internally. Ideally this means that going forward with this maya-usd repo, we could help anticipate changes in core USD and keep the dev branch of maya-usd building against the latest core USD code.

So to the issue here, I dropped the maya-usd repo back to the master branch to illustrate the issue Paul identified here, but once past that, I wouldn't actually expect the master branch to build against 19.10. I have instead been building the dev branch Paul prepared against the very latest USD. I see the same issue in the maya-usd dev branch with core USD includes going missing if we don't add the changes from this PR.

I'm not sure any of that helps the issue here, but hopefully that makes sense? :)

@mattyjams
Copy link
Contributor

I've been tinkering with this a bit more and still don't have a good explanation, but I can confirm that the USD header path is not getting passed into the call to the compiler without this PR.

I set the environment variable VERBOSE=1 when running the build script (and also removed the multiproc-ness from the cmake command for more easily diff-able build logs), and without the changes in this PR, I see this for the first file it tries to compile that tries to include a pxr header:

[ 15%] Building CXX object plugin/pxr/maya/lib/usdMaya/CMakeFiles/usdMaya.dir/shadingModeDisplayColor.cpp.o
cd /home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/plugin/pxr/maya/lib/usdMaya && /pixar/d2/sets/vfx2016a/bin/g++  -DBOOST_PYTHON_NO_PY_SIGNATURES -DGLX_GLXEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES -DLINUX -DMFB_ALT_PACKAGE_NAME=usdMaya -DMFB_PACKAGE_MODULE=UsdMaya -DMFB_PACKAGE_NAME=usdMaya -DPXR_BUILD_LOCATION=usd -DPXR_PLUGIN_BUILD_LOCATION=../plugin/usd -DPXR_PYTHON_ENABLED=1 -DPXR_PYTHON_MODULES_ENABLED=1 -DUSDMAYA_EXPORTS=1 -DusdMaya_EXPORTS -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/include -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/maya/include -I/dist/sw/maya/2018.update3/include -isystem /pixar/d2/sets/vfx2016a/include/python2.7 -isystem /pixar/d2/sets/vfx2016a/include  -msse3  -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs   -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -O2 -g -DNDEBUG -fPIC   -o CMakeFiles/usdMaya.dir/shadingModeDisplayColor.cpp.o -c /home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/shadingModeDisplayColor.cpp
In file included from /home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/colorSpace.h:21:0,
                 from /home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/shadingModeDisplayColor.cpp:16:
/home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/api.h:19:34: fatal error: pxr/base/arch/export.h: No such file or directory
 #include "pxr/base/arch/export.h"

When I add the changes from this PR, I see this instead:

[ 14%] Building CXX object plugin/pxr/maya/lib/usdMaya/CMakeFiles/usdMaya.dir/shadingModeDisplayColor.cpp.o
cd /home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/plugin/pxr/maya/lib/usdMaya && /pixar/d2/sets/vfx2016a/bin/g++  -DBOOST_PYTHON_NO_PY_SIGNATURES -DGLX_GLXEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES -DLINUX -DMFB_ALT_PACKAGE_NAME=usdMaya -DMFB_PACKAGE_MODULE=UsdMaya -DMFB_PACKAGE_NAME=usdMaya -DPXR_BUILD_LOCATION=usd -DPXR_PLUGIN_BUILD_LOCATION=../plugin/usd -DPXR_PYTHON_ENABLED=1 -DPXR_PYTHON_MODULES_ENABLED=1 -DUSDMAYA_EXPORTS=1 -DusdMaya_EXPORTS -I/pixar/ws/trees/mattjohnson/usd_open_source/build/inst/include -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/include -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/maya/include -I/dist/sw/maya/2018.update3/include -isystem /pixar/d2/sets/vfx2016a/include/python2.7 -isystem /pixar/d2/sets/vfx2016a/include  -msse3  -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs   -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -O2 -g -DNDEBUG -fPIC   -o CMakeFiles/usdMaya.dir/shadingModeDisplayColor.cpp.o -c /home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/shadingModeDisplayColor.cpp

And for more easily spotting the difference, here are the build commands together:

# without PR changes
cd /home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/plugin/pxr/maya/lib/usdMaya && /pixar/d2/sets/vfx2016a/bin/g++  -DBOOST_PYTHON_NO_PY_SIGNATURES -DGLX_GLXEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES -DLINUX -DMFB_ALT_PACKAGE_NAME=usdMaya -DMFB_PACKAGE_MODULE=UsdMaya -DMFB_PACKAGE_NAME=usdMaya -DPXR_BUILD_LOCATION=usd -DPXR_PLUGIN_BUILD_LOCATION=../plugin/usd -DPXR_PYTHON_ENABLED=1 -DPXR_PYTHON_MODULES_ENABLED=1 -DUSDMAYA_EXPORTS=1 -DusdMaya_EXPORTS -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/include -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/maya/include -I/dist/sw/maya/2018.update3/include -isystem /pixar/d2/sets/vfx2016a/include/python2.7 -isystem /pixar/d2/sets/vfx2016a/include  -msse3  -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs   -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -O2 -g -DNDEBUG -fPIC   -o CMakeFiles/usdMaya.dir/shadingModeDisplayColor.cpp.o -c /home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/shadingModeDisplayColor.cpp
# with PR changes
cd /home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/plugin/pxr/maya/lib/usdMaya && /pixar/d2/sets/vfx2016a/bin/g++  -DBOOST_PYTHON_NO_PY_SIGNATURES -DGLX_GLXEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES -DLINUX -DMFB_ALT_PACKAGE_NAME=usdMaya -DMFB_PACKAGE_MODULE=UsdMaya -DMFB_PACKAGE_NAME=usdMaya -DPXR_BUILD_LOCATION=usd -DPXR_PLUGIN_BUILD_LOCATION=../plugin/usd -DPXR_PYTHON_ENABLED=1 -DPXR_PYTHON_MODULES_ENABLED=1 -DUSDMAYA_EXPORTS=1 -DusdMaya_EXPORTS -I/pixar/ws/trees/mattjohnson/usd_open_source/build/inst/include -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/include -I/home/mattjohnson/local/open_source_projects/maya-usd/build/build/RelWithDebInfo/maya/include -I/dist/sw/maya/2018.update3/include -isystem /pixar/d2/sets/vfx2016a/include/python2.7 -isystem /pixar/d2/sets/vfx2016a/include  -msse3  -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs   -std=c++11 -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-unused-local-typedefs -O2 -g -DNDEBUG -fPIC   -o CMakeFiles/usdMaya.dir/shadingModeDisplayColor.cpp.o -c /home/mattjohnson/local/open_source_projects/maya-usd/plugin/pxr/maya/lib/usdMaya/shadingModeDisplayColor.cpp

Notice that the only difference is that the second one includes -I/pixar/ws/trees/mattjohnson/usd_open_source/build/inst/include, which is necessary to get the compiler to find the pxr headers.

@seando-adsk
Copy link
Collaborator

I'm not sure what is going on, but we should not need to explicitly add this include path. If you look at the cmake/pxrTargets.cmake from (from the USD build) you'll see taht each target has "${PXR_USD_LOCATION}/include" added to it's include directories. So when you link when a Pixar lib, you automatically inherit those include paths.

There is another PR against our refactoring_sandbox branch (#8) that fixes something related to the USD paths. Perhaps that will fix this issue too, if we made similar changes to master.

HamedSabri-adsk pushed a commit that referenced this pull request Aug 12, 2019
* Make sure the build and install folders have the variant (#2)
* Enable generating compile_commands.json by default
* Make sure the build and install folders have the variant 
* Fix typo in ReadMe
* temporarily revert line endings to windows to do merge
* standardize on linux-style line endings (newline only)

(cherry picked from commit 8073eaf)
@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 12, 2019 via email

@seando-adsk
Copy link
Collaborator

Ah sorry yes when I said "${PXR_USD_LOCATION}/include", what I really meant was "/your/fully/expanded/path/to/usd/include". For example in the target "tf" you should see an INTERFACE_INCLUDE_DIRECTORIES entry like this (after the boost include).

FYI, I copy/pasted that from our pxrTargets.cmake where we have actually replaced the full paths with variables so that the USD build is portable.

@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 12, 2019

Oops, just realized that I attached the files to an email reply - I guess github can't cope with that.

Anyway - yeah, no such entity is in my pxrTargets.cmake (I added a .txt so github would accept the upload). No obviously "wrong" path there which might be the result of a missing var or something either.

pxrConfig.cmake.txt
pxrTargets-release.txt
pxrTargets.cmake.txt

@mattyjams
Copy link
Contributor

Ah, thanks for the clues @seando-adsk!

My pxrTargets.cmake is also missing any INTERFACE_INCLUDE_DIRECTORIES that point to where I'm building USD. That seems like a potential problem with the core USD build, so I'm following up with some folks internally here to see whether we can address that on the USD side.

@seando-adsk
Copy link
Collaborator

I noticed from your files that you are on Linux (above I was referring to the files from Windows - thus the mention of boost). Here is the "tf" section from the "pxrTargets.cmake" file on our Linux machine:

set_target_properties(tf PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "PXR_PYTHON_ENABLED=1"
INTERFACE_INCLUDE_DIRECTORIES "/usr/include/python2.7;/local/S/jenkins/workspace/ecg-usd-full-linux/build/RelWithDebInfo/include;/local/S/jenkins/workspace/ecg-usd-full-linux/build/RelWithDebInfo/include"
)

It's strange yours has two pythons and then a TBB, whereas ours has the path (twice) to the USD include folder. Maybe it has to do with the options used when compiling USD?

@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 13, 2019 via email

@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 13, 2019 via email

@seando-adsk
Copy link
Collaborator

Yes we are using "usd/build_scripts/build_usd.py" to build USD.

And yes, our include folder includes: boost, GL, OpenEXR, opensubdiv, pxr, serial and tbb. We are currently letting USD download and build all of it's dependencies, such as boost and tbb.

Sean

@mattyjams
Copy link
Contributor

I found a solution for this on the core USD side that ensures the correct header include path is written into the pxrTargets.cmake. It should make its way out to the public USD repo soon, but until then, here's the patch:

diff --git a/cmake/macros/Private.cmake b/cmake/macros/Private.cmake
index 2ebd16eb0..623465ed5 100644
--- a/cmake/macros/Private.cmake
+++ b/cmake/macros/Private.cmake
@@ -1135,6 +1135,7 @@ function(_pxr_library NAME)
     #
 
     # Where do we install to?
+    _get_install_dir("include" headerInstallDir)
     _get_install_dir("include/${PXR_PREFIX}/${NAME}" headerInstallPrefix)
     _get_install_dir("lib" libInstallPrefix)
     if(isPlugin)
@@ -1253,6 +1254,8 @@ function(_pxr_library NAME)
             "${CMAKE_BINARY_DIR}/${PXR_INSTALL_SUBDIR}/include"
         PUBLIC
             ${args_INCLUDE_DIRS}
+        INTERFACE
+            $<INSTALL_INTERFACE:${headerInstallDir}>
     )
 
     # XXX -- May want some plugins to be baked into monolithic.

Building core USD with that change, I was then able to build maya-usd against it without the changes in this PR.

@elrond79, when you get a chance, can you give this a shot and see if it resolves the problem for you too?

@pmolodo
Copy link
Contributor Author

pmolodo commented Aug 16, 2019

Yes, with this change to USD core, I can build without this PR!

Having said that, we still need this PR for master, which is targeting usd-19.05, which obviously doesn't have this USD fix.

Once the fix makes it onto a public USD push, then we can drop it from the dev branch... but in the meantime, as Sean's own header include path demonstrates, having some duplicate entries in the include path isn't a big deal. (And as issue #19 demonstrates, people are already running into this problem.)

@mattyjams
Copy link
Contributor

Yup, great point. Just wanted to confirm that the core USD build change sorted out the dev build for you too. Thanks!

@pmolodo
Copy link
Contributor Author

pmolodo commented Oct 18, 2019

I'm going to drop this, since we're "soon" going to be requiring usd-0.19.11 (The exception being AL's usd-0.19.01 PR, but that's basically just to accomodate them, and I don't think they encountered this particular problem...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants