-
Notifications
You must be signed in to change notification settings - Fork 125
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
Set IMATH_VERSION from Imath_VERSION instead of CMAKE_PROJECT_VERSION #145
Set IMATH_VERSION from Imath_VERSION instead of CMAKE_PROJECT_VERSION #145
Conversation
When invoked via FetchContent() from another project, the CMAKE_PROJECT_VERSION variables inherit values from the parent project rather than coming from Imath itself. Signed-off-by: Cary Phillips <[email protected]>
CMakeLists.txt
Outdated
set(IMATH_VERSION_MAJOR ${Imath_VERSION_MAJOR}) | ||
set(IMATH_VERSION_MINOR ${Imath_VERSION_MINOR}) | ||
set(IMATH_VERSION_PATCH ${Imath_VERSION_PATCH}) |
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.
Not for this patch -- because I'm hesitant to introduce any potentially breaking change to the backports -- but if IMATH_VERSION_MAJOR is never different from Imath_VERSION_MAJOR, do we really need the former to exist at all?
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.
Agreed, not for this patch. I created a v3.0.3 tag which will suffice for the current issue. I'll dig a little deeper afterwards.
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.
I removed the IMATH_VERSION_{MAJOR,MINOR,PATCH} variables and replaced their use with the Imath_ ones.
It bugs me that we have some variables prefixed with IMATH_ and some (cmake-provided) prefixed with Imath_, but I'm leery of changing the ones that are already public settings.
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.
Oh geez, I had to look up if cmake variables are case sensitive or not (they are case sensitive). This pattern is moderately confusing.
Use the cmake-provided Imath_VERSION ones instead. Signed-off-by: Cary Phillips <[email protected]>
The old Cmake convention was all-caps PACKAGENAME_FOO, but nowadays preference seem to be PackageName_FOO matching the real name of the package (and PackageNameConfig.cmake, FindPackageName.cmake, etc., for consistency). |
The project(Imath VERSION 3.2.1) call sets Imath_VERSION_MAJOR=3, Imath_VERSION_MINOR=2, and Imath_VERSION_PATCH=1, which is the incentive to use make use of the Imath_ variables. Previously, we were setting the IMATH_ variables and then forming the string to use as the VERSION for the package() call, which seemed backwards. It seems like the fewer variables, the better. |
CMakeLists.txt
Outdated
if (NOT IMATH_VERSION_EXTRA STREQUAL "") | ||
set(IMATH_VERSION "${CMAKE_PROJECT_VERSION}-${IMATH_VERSION_EXTRA}") | ||
set(IMATH_VERSION "${Imath_VERSION}-${IMATH_VERSION_EXTRA}") |
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.
This turns out not to be ok. IMATH_VERSION cascades down to getting put in the exported ImathConfigVersion.cmake as
set(PACKAGE_VERSION "3.1.0-dev")
and that's in fact an invalid cmake package version, which has to be of the form MAJOR.MINOR[.PATCH[.TWEAK]]
We don't want the "-dev" to show up in this variable.
In OIIO, I use the dev designator as a totally separate variable:
set (PROJECT_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
and then it can be directly tested in cmake code, it gets folded into the string that prints for versions, but not into the OpenImageIO_VERSION variable or the exported configs.
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.
Current master Imath's exported config appears to be broken for this reason. (But luckily, 3.0.3 is not. It's mildly broken for a totally different reason. :-))
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.
We've had a rough patch of bad luck in the last few days that isn't really anybody's fault, but I think there are lessons that we can draw from it to make things smoother in the future. One of those lessons is that even the minor patch releases should not have changes to the build scripts added mere hours before a tag is published. All patches should go into the RB-x.y branch and sit for 48 hours without any bugs found (including by downstream projects' CI), and only then should the tag (and NO other changes) be added and release made. (Of course, in a TRUE emergency release, where the prior one is simply too broken to be made any worse even if there are mistakes.)
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.
I'm aware that I'm the one who urged the "-dev" stuff, and I also didn't spot this problem during the PR reviews. I didn't realize the problem until it had already been merged and trickled downstream. Sorry about that.
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.
I'll try proposing a fix for this, since I feel like I'm the one who set us off in the wrong direction.
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.
I don't think we have any reason to do anything special or fancy or non-standard with Imath or OpenEXR, it should be just basic version specification/identification stuff, so parroting exactly what other projects do seems like the best approach. I took inspiration for the original cleanup from OIIO but obviously didn't replicated it properly.
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 #146
* IMATH_VERSION_EXTRA is replaced with IMATH_VERSION_RELEASE_TYPE for consistency with OIIO. * IMATH_VERSION_EXTRA is used only to form IMATH_PACKAGE_STRING Signed-off-by: Cary Phillips <[email protected]>
…AcademySoftwareFoundation#145) * Set IMATH_VERSION from Imath_VERSION instead of CMAKE_PROJECT_VERSION When invoked via FetchContent() from another project, the CMAKE_PROJECT_VERSION variables inherit values from the parent project rather than coming from Imath itself. Signed-off-by: Cary Phillips <[email protected]> * Remove IMATH_VERSION_{MAJOR,MINOR,PATCH} variables Use the cmake-provided Imath_VERSION ones instead. Signed-off-by: Cary Phillips <[email protected]> * IMATH_VERSION is strickly major.minor.patch * IMATH_VERSION_EXTRA is replaced with IMATH_VERSION_RELEASE_TYPE for consistency with OIIO. * IMATH_VERSION_EXTRA is used only to form IMATH_PACKAGE_STRING Signed-off-by: Cary Phillips <[email protected]>
…#145) * Set IMATH_VERSION from Imath_VERSION instead of CMAKE_PROJECT_VERSION When invoked via FetchContent() from another project, the CMAKE_PROJECT_VERSION variables inherit values from the parent project rather than coming from Imath itself. Signed-off-by: Cary Phillips <[email protected]> * Remove IMATH_VERSION_{MAJOR,MINOR,PATCH} variables Use the cmake-provided Imath_VERSION ones instead. Signed-off-by: Cary Phillips <[email protected]> * IMATH_VERSION is strickly major.minor.patch * IMATH_VERSION_EXTRA is replaced with IMATH_VERSION_RELEASE_TYPE for consistency with OIIO. * IMATH_VERSION_EXTRA is used only to form IMATH_PACKAGE_STRING Signed-off-by: Cary Phillips <[email protected]>
When invoked via FetchContent() from another project, the
CMAKE_PROJECT_VERSION variables inherit values from the parent project
rather than coming from Imath itself.
Signed-off-by: Cary Phillips [email protected]