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

Set IMATH_VERSION from Imath_VERSION instead of CMAKE_PROJECT_VERSION #145

Merged
merged 4 commits into from
May 20, 2021

Conversation

cary-ilm
Copy link
Member

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 cary@ilm.com

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 <cary@ilm.com>
CMakeLists.txt Outdated
Comment on lines 27 to 29
set(IMATH_VERSION_MAJOR ${Imath_VERSION_MAJOR})
set(IMATH_VERSION_MINOR ${Imath_VERSION_MINOR})
set(IMATH_VERSION_PATCH ${Imath_VERSION_PATCH})
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

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 <cary@ilm.com>
@lgritz
Copy link
Contributor

lgritz commented May 19, 2021

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

@cary-ilm
Copy link
Member Author

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}")
Copy link
Contributor

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.

Copy link
Contributor

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. :-))

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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 <cary@ilm.com>
@cary-ilm cary-ilm merged commit a774c42 into AcademySoftwareFoundation:master May 20, 2021
cary-ilm added a commit to cary-ilm/Imath that referenced this pull request May 29, 2021
…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 <cary@ilm.com>

* Remove IMATH_VERSION_{MAJOR,MINOR,PATCH} variables

Use the cmake-provided Imath_VERSION ones instead.

Signed-off-by: Cary Phillips <cary@ilm.com>

* 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 <cary@ilm.com>
@cary-ilm cary-ilm mentioned this pull request May 29, 2021
cary-ilm added a commit that referenced this pull request May 30, 2021
…#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 <cary@ilm.com>

* Remove IMATH_VERSION_{MAJOR,MINOR,PATCH} variables

Use the cmake-provided Imath_VERSION ones instead.

Signed-off-by: Cary Phillips <cary@ilm.com>

* 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 <cary@ilm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants