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

Added conan.cmake file version check & download error reporting #374

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

jlschrag
Copy link

@jlschrag jlschrag commented Nov 30, 2021

The current version of the conan.cmake file download in the readme is just a simple check that the file exists. This is problematic if a developer has an outdated version of the file present on their machine and can result in vague error messages later in the process. I've added logic to parse the version number from the file present on their machine and compare with the version in their CMakeLists.txt.

I've also added logic to catch file download errors as errors were previously either ignored or a misleading error message was shown.

Finally, I've updated the conan.cmake file version number to 0.17.0 avoid errors for Visual Studio 2022 users following the readme.

Note: This is a large block of code for a readme. If there is a better place to put it, please let me know.

@CLAassistant
Copy link

CLAassistant commented Nov 30, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Joe Schrag seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

README.md Outdated
@@ -27,12 +27,35 @@ list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

add_definitions("-std=c++11")

set (CONAN_CMAKE_VERSION "0.17.0")
Copy link
Author

@jlschrag jlschrag Nov 30, 2021

Choose a reason for hiding this comment

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

Note: This & the logic below assume that the format of the file version will be the same going forward within the conan.cmake file and in the file download URL. This historically has not always been the case. Version 0.16 appears as "0.16.0" in the file, but "0.16" in the URL. Alternatively, we can hard code the version number into the find command & URL; it just creates two places that have to be changed together.

Copy link
Contributor

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

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

I think this is worth adding since everyone needs to copy paste it... perhaps in a separate example?

https://github.com/prince-chrismc/user-management/blob/9df3631cc2bdedaf3df136cbdf0d77f60bdf796a/backend/cmake/conan-setup.cmake#L6

README.md Outdated
Comment on lines 39 to 40
file(READ "${CMAKE_BINARY_DIR}/conan.cmake" FILE_CONTENTS)
string(FIND "${FILE_CONTENTS}" "# version: ${CONAN_CMAKE_VERSION}" MATCH_RESULT)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you check the hash you should be fine?

Copy link
Author

@jlschrag jlschrag Dec 5, 2021

Choose a reason for hiding this comment

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

Good call!

Turns out the file download call checks the hash of an existing file before downloading. If the file already exists, it returns the message "returning early; file already exists with expected SHA256 hash". I've updated the example.

@jlschrag
Copy link
Author

jlschrag commented Dec 5, 2021

@prince-chrismc Are you saying the CONAN_WRAPPER definition should be added elsewhere in the README?

@prince-chrismc
Copy link
Contributor

Yes a personal preference, the first example should be easy/most simple.

There's no need to make any changes.

@jlschrag
Copy link
Author

jlschrag commented Jan 3, 2022

@prince-chrismc Is this waiting for me to add CONAN_WRAPPER before merge?

@prince-chrismc
Copy link
Contributor

I am not on the Conan team, and they are very busy with the near v2 release.

Last time I said "no needed for changes" so we just need to wait for them to attack this project as well :)

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.

3 participants