Skip to content

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

Open
jlschrag wants to merge 3 commits into
conan-io:developfrom
jlschrag:develop
Open

Added conan.cmake file version check & download error reporting#374
jlschrag wants to merge 3 commits into
conan-io:developfrom
jlschrag:develop

Conversation

@jlschrag

@jlschrag jlschrag commented Nov 30, 2021

Copy link
Copy Markdown

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

CLAassistant commented Nov 30, 2021

Copy link
Copy Markdown

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.

Comment thread README.md Outdated

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

set (CONAN_CMAKE_VERSION "0.17.0")

@jlschrag jlschrag Nov 30, 2021

Copy link
Copy Markdown
Author

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.

@prince-chrismc prince-chrismc left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread 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
Copy Markdown
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?

@jlschrag jlschrag Dec 5, 2021

Copy link
Copy Markdown
Author

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

jlschrag commented Dec 5, 2021

Copy link
Copy Markdown
Author

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

@prince-chrismc

Copy link
Copy Markdown
Contributor

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

There's no need to make any changes.

@jlschrag

jlschrag commented Jan 3, 2022

Copy link
Copy Markdown
Author

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

@prince-chrismc

Copy link
Copy Markdown
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