-
Notifications
You must be signed in to change notification settings - Fork 202
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
clean up pr2 #370
clean up pr2 #370
Conversation
…ra other than declaring their dependence on mayaUsd. mayaUsd target now declares ${CMAKE_BINARY_DIR}/include publicly.
- promoted header files are added as an INTERFACE
… quotes. Either works....
Hi - so, what you've said mostly makes sense to me. The only thing that I think I want to clarify is the distinction between using "" vs <> for headers (and relative vs "absolute") paths. For instance, you say that:
And:
Now, everything you say here is correct - as far as it goes. Both flavors will, indeed, work. However, there's an additional factor in play here, which is the style conventions which we've agreed on now, and are about to formally roll out. Those lay out specific rules for when are where "" vs <> should be used, and so, according to the style guidelines, "" and <> can not be used interchangeably. Specifically, the style guidelines state that <> (with absolute paths) must be used for public header files, and that "" should be used for private ones. (A note on terminology - when I said public and private header files, I'm using the terms in a slightly different way than the That would mean that, for the headers you used in the examples above (which would all meet the definition of public headers), that these forms would be preferred:
...while these forms would be discouraged:
Or, at least, that's how I'm interpreting the style guidelines... did you have a different interpretation? |
Correct, my comment "we can add the header files either by "" or <>. Either flavor works" was more of a general information and I do agree with you that "" and <> can not be used interchangeably. I do agree with following style when used by projects who consume hdMaya.
Which I have applied in this PR. Please see lib/render/mayaToHydra/renderOverride.cpp My main source of confusion is applying the same concept inside the hdMaya project itself. For instance, utils.cpp doesn't really need to include utils.h like this:
same thing to every single source codes inside hdMaya. For example, If utils.cpp wants to include something from inside it's own project, it should be able to do it this way
I would also like to avoid any use of relative path(../) in either CMake or C++ code. I hope this makes sense. I would also like to see other's feedback in our TSC forum around this topic. |
OK, will continue this discussion on the TSC forum if that's what you'd prefer... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Just a few comment blocks in CMake files that I think can get removed.
I'm fine with angle braces everywhere as long as we're using full paths to promoted header files. Though the convention in the core USD code base is to use quotes and full paths for pxr
headers, that is strictly a style choice. @kxl-adsk helped me recognize that with quotes the preprocessor is going to initially fail to find the header when it looks for it by appending the full path to the source file's directory. So it'll end up finding it the same way as if angle braces were used instead.
lib/python/CMakeLists.txt
Outdated
# ----------------------------------------------------------------------------- | ||
# include directories | ||
# ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this comment block get deleted too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, Thanks @mattyjams . Good point, please see 14218de
# ----------------------------------------------------------------------------- | ||
# include directories | ||
# ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this comment block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see 14218de
lib/ufe/CMakeLists.txt
Outdated
# ----------------------------------------------------------------------------- | ||
# include directories | ||
# ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this comment block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see 14218de
# ----------------------------------------------------------------------------- | ||
# promoted headers | ||
# ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this duplicated comment block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see 14218de
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than header style stuff, which I see you're already addressing in #379, looks good!
Do we need PSL at all
This is a follow up PR to
sabrih/MAYA-103365/clean_up_pr1
.What is the point of this PR?
I am going to try to explain this in steps and my hope is that it would make things more clear around these 2 questions:
#358 (comment)
#358 (comment)
Apologies in advance if it is too long.
Prerequisite:
A target has 2 requirements:
Keywords definition:
Having this information in mind, let's have a look at
hdMaya
andrender/mayaToHydra
targets since they are both good examples in the context of this post.Let's start with
hdMaya
with current PR changes:build/usage with heavy focus on header inclusion
To successfully build this target, we obviously need to know where the header files are:
Now by adding ${CMAKE_CURRENT_SOURCE_DIR}, cmake knows exactly all the about the tree structure under hdMaya project.
Inside the project, we can add the header files either by
""
or<>
. Either flavor works.For sake of example, utils.cpp can include it's own header file like this:
utils.cpp can also include other header files inside the project like this:
Now, to successfully use this target, the dependencies obviously need to know where the header files are. This can be done by using INTERFACE. We promote the header files to the
build directory
and add it's location to the INTERFACEDoing so, targets who depend on hdMaya, do get the includes automatically.
For example for
mtoh
project to usehdMaya
, all it needs to do is to declare it's dependency to this library.Here are some examples how source codes inside mtoh include the headers. again you can either use "" or "<>". Either flavor works.
defaultLightDelegate.cpp
#include <hdMaya/delegates/delegateDebugCodes.h>
renderOverride.cpp
Hope you are not too bored by now.