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

Prevent find_package failure if multiple versions are installed #16654

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MiguelBarro
Copy link

The generated protobuf-config-version.cmake sets the Protobuf_WITH_ZLIB, Protobuf_MSVC_STATIC_RUNTIME and Protobuf_BUILD_SHARED_LIBS unconditionally while executing the _check_and_save_build_option(...) macro.

If there are several Protobuf installations available the original code may lead to failure. An example with two installations:

  • A system deployed installation with version 3.12.4.
  • A repo's thirdparty with version 3.19.4
    The user wants it's project to use the thirdparty one by doing:
        find_package(Protobuf 3.19.4 CONFIG REQUIRED PATHS path/to/thirdparty)

The user is not setting the Protobuf_XXX variables in its CMakeLitsts.txt.
If the first config processed is the system deployed it sets the variables to its desired variables, for example, Protobuf_WITH_ZLIB=OFF but is discarded due to the non-matched version.
Then the thirdparty's config is processed but is discarded because requires Protobuf_WITH_ZLIB=ON which is not a real requirement and makes the find operation fail (despite of matching version).

…bles unless it makes actual sense.

Signed-off-by: Guybrush <miguel.barro@live.com>
@MiguelBarro MiguelBarro requested a review from a team as a code owner April 26, 2024 18:22
@MiguelBarro MiguelBarro requested review from mkruskal-google and removed request for a team April 26, 2024 18:22
@zhangskz zhangskz added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Apr 29, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Apr 29, 2024
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

2 participants