-
Notifications
You must be signed in to change notification settings - Fork 251
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
base: develop
Are you sure you want to change the base?
Conversation
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") |
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.
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.
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 think this is worth adding since everyone needs to copy paste it... perhaps in a separate example?
README.md
Outdated
file(READ "${CMAKE_BINARY_DIR}/conan.cmake" FILE_CONTENTS) | ||
string(FIND "${FILE_CONTENTS}" "# version: ${CONAN_CMAKE_VERSION}" MATCH_RESULT) |
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.
If you check the hash you should be fine?
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.
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.
@prince-chrismc Are you saying the CONAN_WRAPPER definition should be added elsewhere in the README? |
Yes a personal preference, the first example should be easy/most simple. There's no need to make any changes. |
@prince-chrismc Is this waiting for me to add CONAN_WRAPPER before merge? |
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 :) |
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.