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

Encapsulating the use of CURL libraries #176

Merged
merged 3 commits into from
Apr 5, 2022
Merged

Encapsulating the use of CURL libraries #176

merged 3 commits into from
Apr 5, 2022

Conversation

jgalan
Copy link
Member

@jgalan jgalan commented Apr 4, 2022

jgalan Ok

We recently included dependency with curl libraries.

Inside this PR I am encapsulating the methods using CURL so that if no curl libraries have been installed in the system the CURL functions used in the code are bypassed.

Perhaps cmake gurus prefer a different add-on. In that case, please do not hesitate to commit any changes here.

@rest-for-physics/core_dev

@jgalan jgalan requested a review from lobis April 4, 2022 12:52
Copy link
Member

@lobis lobis left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I think all this logic should be on the framework library directory, not on the root directory, even though it does the same thing this is only because we add this subdirectory first. I would do something like what I suggested here, if you agree.

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

Plz @lobis commit to apply the changes as you propose directly to this PR.

…`add_definitions` and fixed bad usage of `find_library` when not found
@lobis
Copy link
Member

lobis commented Apr 5, 2022

Plz @lobis commit to apply the changes as you propose directly to this PR.

Now I think it should work, previously it was trying to add the library even if it didn't find it. It would be nice to test it on a system without this library before merging though.

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

I tested by changing the name to a library I dont have installed, and it was working

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

Perhaps at NAF-IAXO is not yet installed, although I requested it. It is latest being compiled nightly?

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

For me at NAF-IAXO (where CURL libraries are not installed) at commit dfd08b2 works properly, perhaps the problem was introduced later on.

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

Now I think it should work, previously it was trying to add the library even if it didn't find it.

Perhaps you got issues with previously cached cmake variables at your build environment?

@lobis
Copy link
Member

lobis commented Apr 5, 2022

I tested by changing the name to a library I dont have installed, and it was working

oh okay, I was just using the documentation as reference, the variable when not defined is not NOTFOUND but <VAR>-NOTFOUND, perhaps this changes between versions.

std::getline(std::ifstream(filename), file_content, '\0');
#else
ferr << "TRestTools::POSTRequest. REST framework was compiled without CURL support" << endl;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should create a RESTException for these cases. Shall I create an issue about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, if you like, please, explain at the issue how do you want to handle it. For the moment we use no expections, as you see, as it is it just prompts a warning message, then does nothing. Not sure if in this particular case it requires of error handling.

Copy link
Member

Choose a reason for hiding this comment

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

I would say wherever we have exit() in the code we should replace by a throw with an exception handler. Perhaps not for this particular case...

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

I tested by changing the name to a library I dont have installed, and it was working

oh okay, I was just using the documentation as reference, the variable when not defined is not NOTFOUND but <VAR>-NOTFOUND, perhaps this changes between versions.

Yes, in my case it was also the format <VAR>-NOTFOUND I thought the cmake instruction MATCH just checks the string contains the keyword, while STREQUAL requires that is exactly the same.

@jgalan jgalan merged commit 2bc6d3a into master Apr 5, 2022
@jgalan jgalan deleted the jgalan_curl branch April 5, 2022 17:08
@lobis
Copy link
Member

lobis commented Apr 5, 2022

I tested by changing the name to a library I dont have installed, and it was working

oh okay, I was just using the documentation as reference, the variable when not defined is not NOTFOUND but <VAR>-NOTFOUND, perhaps this changes between versions.

Yes, in my case it was also the format <VAR>-NOTFOUND I thought the cmake instruction MATCH just checks the string contains the keyword, while STREQUAL requires that is exactly the same.

oh, then we should use that instead!

Its added on cdacf67 @jgalan

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.

None yet

3 participants