-
Notifications
You must be signed in to change notification settings - Fork 253
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
Fixes #570: Do not remove CMAKE_MODULE_PATH if already set on find_package() #571
Conversation
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.
Thanks for your contribution @curlybeast
I don't fully get what is the difference, looks similar behavior to me.
Maybe having a unit test that would fail without the change would clarify it (and a test seems necessary anyway). Do you think you could try to contribute a test too? If not, don't worry, just tell us, and we will try to help with that.
UPDATE: Sorry I hadn't seen #570, I have added a reference in this PR message.
I know understand the reasons. Still, that further reveals the importance of adding a test to cover this test for now and to avoid future breakage.
Using strings as before means that subsequent runs of that function may change the originally saved string irrevocably, which I believe is what is happening.
|
I've added the beginnings of a test (to the same branch / PR) which replicate the If that is the problem, the question is how to test this effectively without requiring a bunch of pre-installed libraries. Thoughts? |
This is good, exactly the reason why adding the tests are important :) Indeed do not depend on external packages if possible It is possible to create simple packages locally, that simulate the openssl package behavior, with an internal find_package or whatever (when using CMakeDeps, this will not happen, not sure about your setup, if you were using openssl in a different way, not via CMakeDeps). |
add_executable(app main.cpp) | ||
target_link_libraries(app hello::hello bye::bye) |
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.
The executable build can be removed for the test
tests/test_smoke.py
Outdated
run("cmake .. -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -DCMAKE_BUILD_TYPE=Release Module -DCMAKE_C_COMPILER=/usr/bin/cc", check=False) | ||
out, _ = capfd.readouterr() | ||
assert "We should be seeing this warning, if we do the test works" in out | ||
run("cmake --build .") |
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.
This line an be removed
find_program(CCACHE ccache) | ||
find_package(OpenSSL) | ||
find_package(ZLIB) | ||
find_package(prometheus-cpp) |
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.
This would be the thing to simplify, maybe adding a fake openssl-config.cmake
in another folder and adding it to the CMAKE_PREFIX_PATH?
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.
Yea, these are the find_package()
calls before the problem occurs.
I'll do some digging in my environment to pinpoint exactly what it is.
Hi @curlybeast - I've sync'ed up the changes with the |
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.
LGTM
Thanks @curlybeast - the issue happened in a very specific case where two nested find_package
calls were satisfied by a CMake FIND module, rather than a config. Only in that scenario was CMAKE_MODULE_PATH
incorrectly restored. Your solution fixes this.
We discovered a second issue - some recipes can define cpp_info.builddirs
, which result in paths being prepended to CMAKE_MODULE_PATH
- those were being lost too. Happy to report your proposed solution also fixes that bug :)
I've added tests for both situations.
Thank you for the help on this @jcar87, glad to hear I could help the project and that we found / fixed other related issues too! :) |
This fixes the issue for me.
Close #570