Skip to content

set version for project() and add CPack support #15281

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

Closed
wants to merge 5 commits into from

Conversation

zjyhjqs
Copy link
Contributor

@zjyhjqs zjyhjqs commented Oct 13, 2024

Note: the version like 8.11.0-DEV is not a valid version for project(), so need to extract the major, minor and patch parts.

CMakeLists.txt Outdated
set(CURLVERSION "${CURL_VERSION}")
set(VERSIONNUM "${CURL_VERSION_NUM}")
set(CURLVERSION "${LIBCURL_VERSION}")
set(VERSIONNUM "${LIBCURL_VERSION_NUM}")
Copy link
Member

@vszakats vszakats Oct 13, 2024

Choose a reason for hiding this comment

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

I suggest renaming variables in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've separated it into a commit. If that's not enough I can create a new PR.

Copy link
Member

@vszakats vszakats Oct 13, 2024

Choose a reason for hiding this comment

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

I'd suggest a separate PR. That said, what is the reason to rename this variable? It can be argued it's both curl and libcurl version, and since it has been CURL_ for a long time, why change now?

edit: CURL_ is also the namespace we use for curl-specific CMake variables. (And LIBCURL_PC_ but that is a separate, libcurl-specific namespace.) TL;DR: existing name looks fine to me.

Copy link
Contributor Author

@zjyhjqs zjyhjqs Oct 13, 2024

Choose a reason for hiding this comment

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

CURL_VERSION will be initialized by project() (without the -DEV as suffix because the syntax rejects). The variables related to project() should be generated by project() IMO, though I'm not insist on it.

Edit: Since CMake 3.30, behaviour of variables generated by project has been changed. Though it doesn't affect <Project>_VERSION* now, I think it'd better not to set CURL_VERSION explicitly.

So, the renaming is related to setting the project(VERSION). Should this be extracted to a PR?

Copy link
Member

@vszakats vszakats Oct 13, 2024

Choose a reason for hiding this comment

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

Oh, so project() is setting the CURL_VERSION and *_MAJOR/MINOR/PATCH variables automatically, but also differently depending on version and/or CMP policy. E.g. cmake 3.30.x is setting them.

Before this patch we already set CURL_VERSION to 8.11.0-DEV. This changes to 8.11.0 when using project().

What is the advantage of using project() for setting the CURL_VERSION variable? Why do we need this?

edit: link for reference: https://cmake.org/cmake/help/latest/command/project.html#options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wouldn't we need this to catch non-DEV versions?:

string(REGEX REPLACE "([0-9]+\.[0-9]+)\.([0-9]+.*)" "\\2" CPACK_PACKAGE_VERSION_PATCH "${LIBCURL_VERSION}")

Yes. I've tested both DEV and non-DEV versions. This works fine.

Copy link
Member

Choose a reason for hiding this comment

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

Would you want to do the renaming from LIBCURL_VERSION* to _cmake_version*?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CMAKE_VERSION is the version of CMake. But we could add an underscore prefix (with full lower-case)?

Copy link
Member

Choose a reason for hiding this comment

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

I meant rename to _curl_version_*, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant rename to _curl_version_*, sorry.

done

@zjyhjqs zjyhjqs force-pushed the feat/cpack branch 3 times, most recently from ecf81ec to f348f8e Compare October 13, 2024 15:49
@vszakats
Copy link
Member

Thank you @zjyhjqs, this is merged now.

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

Successfully merging this pull request may close these issues.

None yet

2 participants