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

Improve generated header setup in MaterialXCore #940

Conversation

theblackunknown
Copy link
Contributor

@theblackunknown theblackunknown commented May 8, 2022

Description

This PR improves how MaterialXCore generated header is handled in the CMake setup.
It write generated sources in the buildtree rather than the source tree, and uses CMAKE_CURRENT_LIST_DIR instead of CMAKE_CURRENT_SOURCE_DIR, then MaterialXCore .gitignore file is not needed anymore.
I have encountered issues with it while developing a materialx port for vcpkg C++ package manager (cf. microsft/vcpkg#24614).

Those changes will leads to more reliable and reproducible results.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 8, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: theblackunknown / name: MACHIZAUD Andréa (55a8241, fc87a98)

@theblackunknown
Copy link
Contributor Author

Regarding the CLA check, I have both sent a signed PDF and use the Github check link to sign it.
Let me know how to update the check for it

@theblackunknown theblackunknown force-pushed the fix-materialxcore-generated-header branch 2 times, most recently from 3571cd0 to fbe71b1 Compare May 8, 2022 21:34
@theblackunknown theblackunknown changed the title Improve generator header setup in MaterialXCore Improve generated header setup in MaterialXCore May 8, 2022
@jstone-lucasfilm
Copy link
Member

@theblackunknown Thanks for putting together this propoal! You can often resolve the EasyCLA detection by adding a comment including the following text:

/easycla

If that doesn't resolve the issue, then I would recommend writing up an LFX support ticket as described here:

#940 (comment)

@theblackunknown
Copy link
Contributor Author

/easycla

1 similar comment
@theblackunknown
Copy link
Contributor Author

/easycla

@theblackunknown theblackunknown force-pushed the fix-materialxcore-generated-header branch from b97371b to fc87a98 Compare May 9, 2022 07:39
@theblackunknown
Copy link
Contributor Author

@jstone-lucasfilm I figured out the EasyCLA issue !
Note that I have also updated the way cppcheck is done by relying on CMake generated compile commands rather than an explicit command-line configuration as it was done before, this should improve the robustness of cppcheck too.

@theblackunknown
Copy link
Contributor Author

It seems that I need your approval to run the CI and make sure this is working as expected

@@ -1,7 +1,7 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Generated.h.in ${CMAKE_CURRENT_SOURCE_DIR}/Generated.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/Generated.h.in ${CMAKE_CURRENT_BINARY_DIR}/Generated.h)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the need for the generated header to be in CMAKE_CURRENT_BINARY_DIR, and that part of the change seems like a clear improvement.

Can you provide some clarity on the motivation for referencing source files in CMAKE_CURRENT_LIST_DIR rather than CMAKE_CURRENT_SOURCE_DIR? I'm not against this idea, but I want to make sure that I understand the logic behind the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this context it does not matter that much and both are equivalent, so I will probably revert this change to keep the diff minimal.

My habit though it to use CMAKE_CURRENT_LIST_DIR when I can as it always refers to the CMake file currently being processed as the other one may not.

Here is a page with a bit more details and examples if you want to dig this : https://cgold.readthedocs.io/en/latest/tutorials/cmake-sources/common.html#cmake-current-list-dir-vs-cmake-current-source-dir

theblackunknown and others added 3 commits May 10, 2022 10:16
`source/MaterialXCore/.gitignore` is this not needed anymore.

This leads to more reliable and reproducible results.

I have ran into issues while developing materialx vcpkg port (cf. microsft/vcpkg#24614)
@theblackunknown theblackunknown force-pushed the fix-materialxcore-generated-header branch from 97a2177 to fc3667e Compare May 10, 2022 08:16
Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks @theblackunknown!

@jstone-lucasfilm jstone-lucasfilm merged commit b1ba83b into AcademySoftwareFoundation:main May 10, 2022
@theblackunknown theblackunknown deleted the fix-materialxcore-generated-header branch May 11, 2022 06:10
jstone-lucasfilm added a commit that referenced this pull request May 14, 2022
This changelist removes a gitignore file that is no longer required in MaterialXCore, following the generated header improvements in #940.
Michaelredaa pushed a commit to Michaelredaa/MaterialX that referenced this pull request Oct 21, 2023
…ation#940)

This PR improves how MaterialXCore generated header is handled in the CMake setup.
It writes generated sources in the build tree rather than the source tree, so the MaterialXCore .gitignore file is not needed anymore.
I have encountered issues with it while developing a materialx port for vcpkg C++ package manager (cf. microsft/vcpkg#24614).
Michaelredaa pushed a commit to Michaelredaa/MaterialX that referenced this pull request Oct 21, 2023
This changelist removes a gitignore file that is no longer required in MaterialXCore, following the generated header improvements in AcademySoftwareFoundation#940.
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.

2 participants